I need help on hyperlink filtering in response and flow if like below.
1. I have article data response in article data JSON response (we recived pasre JSON)
[Actual Response from Service provider]
{
"article": [
{
"name": "Test links",
"content": "<p>test <a href=\"https://en.wikipedia.org/wiki/Season\">Teslink</a></p>"
}
]
}
[Getting response from singlet servlet] [public class ArticleServlet extends SlingSafeMethodsServlet]
{"article":[{"name":"Test links","approverOrderNumber":0,"content":"<p>test <img class="cq-LinkChecker cq-LinkChecker--prefix cq-LinkChecker--invalid" src="/libs/cq/linkchecker/resources/linkcheck_o.gif" alt="invalid link: \" title="invalid link: \" border="0">eGain1<img class="cq-LinkChecker cq-LinkChecker--suffix cq-LinkChecker--invalid" src="/libs/cq/linkchecker/resources/linkcheck_c.gif" border="0"></p>"
}
]
}
So its unnecessary adds "LinkChecker cq-LinkChecker--prefix cq-LinkChecker--invalid" these link in contents and its break everything in response.
How can we stop link checker service in aem itself.
one method i seen is adding "x-cq-linkchecker="skip" but is there any other solution ?
Is it mandatory to add "x-cq-linkchecker="skip" in link ?
I tried below also then it removed "href" completely and send value as "href=/" in response.
Solved! Go to Solution.
Views
Replies
Total Likes
Link checker checks anchor links in servlet response & rewrites only in following scenarios.
If "a:href" present in the Day CQ Link Checker Transformer configuration. if your requirement is to
Disable link checker only for JSON response content type
1. If you have added "application/json" content type in rewrite config under /apps/project/config/rewriter/project then remove this content type from configuration.
2. Set content type to servlet json response in servlet so that link checker rewrite will not be applied this content type since this content type is removed in step 1.
response.setContentType("application/json; charset=UTF-8");
Above 2 steps will resolve link checker issue on json content type response.
Servlet JSON response before fix:
Servlet JSON response after fix:
As i mentioned in above comment no need to removing a:href or disabling link checker from "Day CQ Link Checker Transformer" for the issue which your facing because this will completely remove link checker for other content type as well.
so, just add content type in servlet response as mentioned below. if you have already added this then please share the header & response tab screenshot from browser network tab when we can see whether content type is set or not in response headers.
response.setContentType("application/json; charset=UTF-8");
You will get href="\" i.e. link getting removed when there is no proper content type is set refer below screenshot where content type is not set.
-Manjunath
If you're referring this on publisher then, you should disable all Link Checker service configs.
On author, try modifying the Day CQ Link Checker Transformer: remove a:href from the Rewrite Elements config.
I tried all option of disabling the service still this doesn't work. In my servlet i am getting article content from 3rd part system so I can't add skip tag in content.
Is there is any way programmatically we can disable link checker service while sending out JSON response.
Views
Replies
Total Likes
Link checker checks anchor links in servlet response & rewrites only in following scenarios.
If "a:href" present in the Day CQ Link Checker Transformer configuration. if your requirement is to
Disable link checker only for JSON response content type
1. If you have added "application/json" content type in rewrite config under /apps/project/config/rewriter/project then remove this content type from configuration.
2. Set content type to servlet json response in servlet so that link checker rewrite will not be applied this content type since this content type is removed in step 1.
response.setContentType("application/json; charset=UTF-8");
Above 2 steps will resolve link checker issue on json content type response.
Servlet JSON response before fix:
Servlet JSON response after fix:
As i mentioned in above comment no need to removing a:href or disabling link checker from "Day CQ Link Checker Transformer" for the issue which your facing because this will completely remove link checker for other content type as well.
so, just add content type in servlet response as mentioned below. if you have already added this then please share the header & response tab screenshot from browser network tab when we can see whether content type is set or not in response headers.
response.setContentType("application/json; charset=UTF-8");
You will get href="\" i.e. link getting removed when there is no proper content type is set refer below screenshot where content type is not set.
-Manjunath
Views
Replies
Total Likes
Hi @sagrawal
If your project doesn't have custom link rewrite service config then you can ignore step2 mentioned above & it will be referred to OOTB rewrite config present under /libs/cq/config/rewriter/default which does not have application/json in contentType list.
so, setting content type to servlet response as per step1 will resolve your issue.
-Manjunath
Views
Replies
Total Likes
Thanks for your response. If I remove the a:link then href is repaced with "\" in JSON response.
I am sending JSON response using - public class ArticleServlet extends SlingSafeMethodsServlet {}
response.getWriter().write(articledata json);
Below response i am receiving
content":"<p>test <a href="\">wiki</a></p>"
Views
Replies
Total Likes
Hi @sagrawal
As i mentioned in above comment no need to removing a:href or disabling link checker from "Day CQ Link Checker Transformer" for the issue which your facing because this will completely remove link checker for other content type as well.
so, just add content type in servlet response as mentioned below. if you have already added this then please share the header & response tab screenshot from browser network tab when we can see whether content type is set or not in response headers.
response.setContentType("application/json; charset=UTF-8");
You will get href="\" i.e. link getting removed when there is no proper content type is set refer below screenshot where content type is not set.
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
You’re welcome
Sure, i will check your query related "Custom Component: Style tab is not showing" & provide if any inputs that i can share.
Views
Replies
Total Likes
Views
Likes
Replies