Linkchecker removing href value | Community
Skip to main content
Radha_Krishna_N
Level 3
October 24, 2017
Solved

Linkchecker removing href value

  • October 24, 2017
  • 3 replies
  • 6252 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by kautuk_sahni

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

3 replies

kautuk_sahni
Community Manager
kautuk_sahniCommunity ManagerAccepted solution
Community Manager
October 24, 2017

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
Radha_Krishna_N
Level 3
October 24, 2017

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

Level 2
October 10, 2018

This is working