I encountered an odd issue while I was testing my Chef provider for OSGi configurations. I tried to amend com.day.cq.rewriter.linkchecker.impl.LinkCheckerImpl, but it turned out it was not possible.
This is its default configuration:
PID com.day.cq.rewriter.linkchecker.impl.LinkCheckerImpl
TITLE Day CQ Link Checker Service
DESCRIPTION Performs asynchronous checking of external links.
BUNDLE Day Communique 5 Rewriter (com.day.cq.cq-rewriter), Version 5.6.4
ID VALUE NAME VALUES DESCRIPTION
scheduler.period 5 Scheduler Period
scheduler.concurrent false scheduler.concurrent.name
service.bad_link_tolerance_interval 48 Bad Link Tolerance Interval
service.check_override_patterns ["^system/"] Link Check Override Patterns
service.cache_broken_internal_links false Cache Broken Internal Links
service.special_link_prefix ["#","${","<!--","data:","javascript:","mailto:","z:"] Special Link Prefixes
service.special_link_patterns Special Link Patterns
My provider eventually executes cqcfg command like this:
Unfortunately I ended with non-zero exit code with the following message:
bash: !--": event not found
The root cause was quite straightforward - all parameters should be enclosed with single quotes and not the double ones (reference). I've updated my code, but cqcfg was still not working:
CURL ERROR 3: URL malformed. The syntax was not correct.
I came up with the idea to encode all the values in my ruby code, but it turned out it was a dead end. I eventually discovered that CQ UNIX Toolkit can do that automatically thanks to _urlencode function from cqapi, so encoding of already encoded values is a bad idea.
All in all I did a comparison of HTTP requests generated by the browser and cqcfg command and the difference was as follows:
Browser
cqcfg
service.check_override_patterns=%5Esystem%2F
service.check_override_patterns=^system%2F
service.special_link_prefix=%23
service.special_link_prefix=#
service.special_link_prefix=%24%7B
service.special_link_prefix=%24{
service.special_link_prefix=%3C!--
service.special_link_prefix=<%21--
As you can see some characters were not encoded, so I decided to dig into the cqcfg and cqapi code.
In this PR:
new encoding rules were added
redundant sed command from cqcfg was removed (more detailed explanation has been placed in this commit)
Hey,
I encountered an odd issue while I was testing my Chef provider for OSGi configurations. I tried to amend
com.day.cq.rewriter.linkchecker.impl.LinkCheckerImpl
, but it turned out it was not possible.This is its default configuration:
My provider eventually executes
cqcfg
command like this:Unfortunately I ended with non-zero exit code with the following message:
The root cause was quite straightforward - all parameters should be enclosed with single quotes and not the double ones (reference). I've updated my code, but
cqcfg
was still not working:I came up with the idea to encode all the values in my ruby code, but it turned out it was a dead end. I eventually discovered that CQ UNIX Toolkit can do that automatically thanks to
_urlencode
function fromcqapi
, so encoding of already encoded values is a bad idea.All in all I did a comparison of HTTP requests generated by the browser and
cqcfg
command and the difference was as follows:service.check_override_patterns=%5Esystem%2F
service.check_override_patterns=^system%2F
service.special_link_prefix=%23
service.special_link_prefix=#
service.special_link_prefix=%24%7B
service.special_link_prefix=%24{
service.special_link_prefix=%3C!--
service.special_link_prefix=<%21--
As you can see some characters were not encoded, so I decided to dig into the
cqcfg
andcqapi
code.In this PR:
sed
command fromcqcfg
was removed (more detailed explanation has been placed in this commit)