Skip to content

July 22, 2013

CQ 5.5 and Link Rewriter Failures

by Andreas Schaefer

In CQ 5.5 one can rewrite links by extending a RequestRewriter interface inside an OSGi service. This way links can be dynamically adjusted to external views or can be adjusted to internal conditions. In my current project we use this extensively and for most parts it works fine. That said for a few pages that did not work at all exposing internal structures to the client. It took me a while to discover the cause but fixing as quite simple.Because of the Dispatcher Cache it is not that simple to see if a link is due to a bug from the past or due to the current environment. One way to see it is to circumventing the Cache by adding a question mark to the end of the URL but that might now work when the URLs is rewritten. So after some back and forth I figured out that a given page was returning internal links. Settings the Log Level of my Link Rewriter class to DEBUG is was able to see that the Link Rewriter class was never called and so my Link Rewriter class was not at fault.

Eventually I took the page content and placed it into an HTML Editor and checked it for errors and voila the header meta entry ‘description’ contained two double quotes which will terminate the property prematurely. Most HTML Browsers will ignore this issue but the Link Rewriter implementation of CQ 5.5 is using a SAX Parser which is tripped off and does not process sending the content unfiltered to the client causing my issue.

The fix was quite simple. I went to the Tag Lib entry that prints out the meta tags and XML Encoded the content using the Apache’s Commons Lang StringUtils.encodeXML() method. After installing the fix the page is now adjusted like the rest of it.

  • Andy
Read more from Uncategorized

Leave a comment