Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Linkchecker removing href value

Avatar

Level 4

Hi All,

AEM version 6.1 SP1

I am trying to author a link url - https://www.xyz.com/abc.jsp?filters={%22key%22:[%22value%22]} but linkchecker is removing this and logging a warning message in error log file


23.10.2017 21:30:28.665 *WARN* [0:0:0:0:0:0:0:1 [1508808628533] GET /content/repl.template.html HTTP/1.1] com.day.cq.rewriter.linkchecker.impl.LinkCheckerImpl Ignoring malformed URI: java.net.URISyntaxException: Illegal character in query at index 73: https://www.xyz.com/abc.jsp?filters={%22key%22:[%22value%22]}

23.10.2017 21:30:28.665 *WARN* [0:0:0:0:0:0:0:1 [1508808628533] GET /content/repl.template.html HTTP/1.1] org.apache.sling.xss.impl.HtmlToHtmlContentContext AntiSamy warning: The a tag contained an attribute that we could not process. The href attribute had a value of "https://www.xyz.com/abc.jsp?filters={%22key%22:[%22value%22]}". This value could not be accepted for security reasons. We have chosen to remove this attribute from the tag and leave everything else in place so that we could process the input.

Also I tried validating the url as below

// throws URI Syntax Exception: Linkchecker uses Java.net.URI

URI uri = new URI("https://www.xyz.com/abc.jsp?filters={%22key%22:[%22value%22]}");

System.out.println(uri.getQuery());

//Works fine!! - org.apache.commons.validator.routines.UrlValidator

UrlValidator urlValidator = new UrlValidator();

System.out.println(urlValidator.isValid("https://www.xyz.com/abc.jsp?filters={%22key%22:[%22value%22]}"));


how to resolve this issue on both author and publish instances?

Thanks,

Radha Krishna N

1 Accepted Solution

Avatar

Correct answer by
Administrator

Option 1:

You can add x-cq-linkchecker="valid" parameter in the <a> tag to make sure that links are always marked as valid by CQ. In this case, link checker will check the link but will mark it valid.

Option 2:- You can disable external link checker entirely by going to felix console

Screen%2Bshot%2B2011-12-15%2Bat%2B9.54.59%2BAM.png

Really Good read:- AEM Experience: AEM Link Checker: fixing broken links that aren't broken.

It will cover  4 types of links that Youve written that have thrown errors:

href="tel:123-456-7890"

href="*|FORWARD|*"

href="http://www.facebook.com/sharer/sharer.php?u=*|URL:ARCHIVE_LINK_SHORT|*"

href="http://twitter.com/intent/tweet?text=*|URL:MC_SUBJECT|*: *|URL:ARCHIVE_LINK_SHORT|*"

~kautuk



Kautuk Sahni

View solution in original post

3 Replies

Avatar

Correct answer by
Administrator

Option 1:

You can add x-cq-linkchecker="valid" parameter in the <a> tag to make sure that links are always marked as valid by CQ. In this case, link checker will check the link but will mark it valid.

Option 2:- You can disable external link checker entirely by going to felix console

Screen%2Bshot%2B2011-12-15%2Bat%2B9.54.59%2BAM.png

Really Good read:- AEM Experience: AEM Link Checker: fixing broken links that aren't broken.

It will cover  4 types of links that Youve written that have thrown errors:

href="tel:123-456-7890"

href="*|FORWARD|*"

href="http://www.facebook.com/sharer/sharer.php?u=*|URL:ARCHIVE_LINK_SHORT|*"

href="http://twitter.com/intent/tweet?text=*|URL:MC_SUBJECT|*: *|URL:ARCHIVE_LINK_SHORT|*"

~kautuk



Kautuk Sahni

Avatar

Level 4

Hi Kautuk

Link checker is disabled and added x-cq-linkchecker="valid".

In the log file

*WARN* [0:0:0:0:0:0:0:1 [1508808628533] GET /content/repl.template.html HTTP/1.1] org.apache.sling.xss.impl.HtmlToHtmlContentContext AntiSamy warning: The a tag contained an attribute that we could not process. The href attribute had a value of "https://www.xyz.com/abc.jsp?filters={%22key%22:[%22value%22]}". This value could not be accepted for security reasons. We have chosen to remove this attribute from the tag and leave everything else in place so that we could process the input.

Finally I add context and x-cq-linkchecker="skip" to the a tag as below then url rendered correctly
<a href="{url @context='unsafe'}" x-cq-linkchecker="skip"> test </a>

thanks,

Radha Krishna N