Steps to bypass URL validation for special characters in the LinkChecker

Learn how to bypass URL validation for special characters in the LinkChecker by using an attribute to keep the link intact.

Description description

Environment

  • AEM as a Cloud Service
  • AEM 6.5.17

Issue/Symptoms


A custom component is needed to render a link containing special characters that are invalid for a URL. Even if the Disable Checking option in the LinkChecker configuration is set as true, the LinkChecker still validates and removes the link from the rendered HTML.





For example:

A link that includes the characters {" and "} that are not valid for a URL.

<span><a href="{testURL}">TEST URL</a></span>

The LinkChecker will remove the link from the rendered HTML

<span>>TEST URL</span>

A URISyntaxException is then logged in error.log as a consequence of this validation process.

23.01.2024 12:43:34.500 *WARN* [ 000.000.000.000 [ 1705981414300] GET /content/wknd/language-masters/en/test.html HTTP/1.1] com.day.cq.rewriter.linkchecker.impl.LinkCheckerImpl Ignoring malformed URI: java.net.URISyntaxException: Illegal character in path at index 0: {testURL}

Resolution resolution

Add the x-cq-linkchecker="skip" attribute to the link in the respective HTL (HTML Template Language) component. This attribute instructs the LinkChecker to bypass the URL validation completely.

For example:

If a link uses the characters {" and "} that are invalid in a URL.
< span><a x-cq-linkchecker="skip" href="{testURL}">TEST URL</a></span>

It (link) remains in the rendered HTML.
< span><a x-cq-linkchecker="skip" href="{testURL}">TEST URL</a></span>

recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f