Current Behavior
Building a Link object with the LinkManager, containing an external URL with a properly encoded URL parameter, breaks the URL encoding.
build with the LinkManager, so all links are handled in the same way, link target can be controlled and so it can directly be used in HTL, decodes the url parameter:
We experience the same issue with 2.22.12, decoding in LinkBuilder and then encoding in default path processor breaks %26 (ampersand) param value in the link.
Bug Report
Current Behavior Building a
Link
object with theLinkManager
, containing an external URL with a properly encoded URL parameter, breaks the URL encoding.For example: a Twitter share link with the
url
parameter encoded, as is described in: https://developer.twitter.com/en/docs/twitter-for-websites/tweet-button/guides/web-intent#:~:text=Hello%2520World-,url,t.co%C2%A0to%20the%20number%20of%20characters%20specified%20by%C2%A0short_url_length.,-https%253A%252Fbuild with the
LinkManager
, so all links are handled in the same way, link target can be controlled and so it can directly be used in HTL, decodes theurl
parameter:https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.aemcomponents.dev%2Fcontent%2Fcore-components-examples%2Flibrary%2Fcore-content%2Fbutton.html&text=%C2%A9%20Core%20Components%20URI%20Link%20Encoding%20bug
leads to the following Link:
https://twitter.com/intent/tweet?url=https://www.aemcomponents.dev/content/core-components-examples/library/core-content/button.html&text=%C2%A9%20Core%20Components%20URI%20Link%20Encoding%20bug
instead of:
https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.aemcomponents.dev%2Fcontent%2Fcore-components-examples%2Flibrary%2Fcore-content%2Fbutton.html&text=%C2%A9%20Core%20Components%20URI%20Link%20Encoding%20bug
Expected behavior/code Encoded URL parameters, shouldn't be decoded, in all cases.
Environment
Possible Solution LinkUtil should be fixed: https://github.com/adobe/aem-core-wcm-components/blob/3d55a142fdca4cea36a7459d3ed1ae5008da3666/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/link/LinkUtil.java#L54