From ac464a2b4f5d19fc93d9f5136a24e7217b93edfc Mon Sep 17 00:00:00 2001 From: cristic83 Date: Mon, 16 Oct 2023 15:16:53 +0300 Subject: [PATCH 1/2] [SITES-16535] Links with hashes "#" in button components are URL encoded when saved (#2598) Co-authored-by: cioriia --- .../cq/wcm/core/components/internal/link/LinkUtil.java | 8 +++++--- .../wcm/core/components/internal/link/LinkUtilTest.java | 8 ++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/link/LinkUtil.java b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/link/LinkUtil.java index 8855b48fff..4743c05fa9 100644 --- a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/link/LinkUtil.java +++ b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/link/LinkUtil.java @@ -118,7 +118,7 @@ public static String escape(final String path, final String queryString, final S } } else { escaped = sb.append("#") - .append(replaceEncodedCharacters(URLEncoder.encode(fragment, StandardCharsets.UTF_8.name()))) + .append(replaceEncodedCharactersInFragment(URLEncoder.encode(fragment, StandardCharsets.UTF_8.name()))) .toString(); } } @@ -212,7 +212,7 @@ private static String newPlaceholder(final String str) { return placeholderBuilder.toString(); } - private static String replaceEncodedCharacters(final String str) { + private static String replaceEncodedCharactersInFragment(final String str) { return str.replace("%2B", "+") .replace("%3D", "=") .replace("%7E", "~") @@ -225,6 +225,8 @@ private static String replaceEncodedCharacters(final String str) { .replace("%27", "'") .replace("%28", "(") .replace("%29", ")") - .replace("%2C", ","); + .replace("%2C", ",") + .replace("%2F", "/") + .replace("%3F", "?"); } } diff --git a/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/internal/link/LinkUtilTest.java b/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/internal/link/LinkUtilTest.java index 5104bbfe1a..68457255f6 100644 --- a/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/internal/link/LinkUtilTest.java +++ b/bundles/core/src/test/java/com/adobe/cq/wcm/core/components/internal/link/LinkUtilTest.java @@ -55,4 +55,12 @@ void decode_whenCampaignPatternIsPresentInTheString_thenCampaignPatternIsNotAffe String decodedPath = LinkUtil.decode(encodedPath); assertEquals(encodedPath, decodedPath); } + + @Test + void escape_whenEscapingPathWithFragment_thenFragmentForwardSlashIsNotEncoded() throws UnsupportedEncodingException { + String path = "https://google.com"; + String fragment = "/assets/2/1529/RES176341/report"; + String escapedPAth = LinkUtil.escape(path, null, fragment); + assertEquals(path+ "#" + fragment, escapedPAth); + } } From 6a102d1d5879d142123a547c00e2d226e475a636 Mon Sep 17 00:00:00 2001 From: Cristian Date: Tue, 17 Oct 2023 14:55:32 +0300 Subject: [PATCH 2/2] [SITES-16477] Update SDK_URL from documentservices to acrobatservices (#2600) --- .../pdfviewer/v1/pdfviewer/clientlibs/site/js/pdfviewer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/src/content/jcr_root/apps/core/wcm/components/pdfviewer/v1/pdfviewer/clientlibs/site/js/pdfviewer.js b/content/src/content/jcr_root/apps/core/wcm/components/pdfviewer/v1/pdfviewer/clientlibs/site/js/pdfviewer.js index f2f3378236..d99b29c7be 100644 --- a/content/src/content/jcr_root/apps/core/wcm/components/pdfviewer/v1/pdfviewer/clientlibs/site/js/pdfviewer.js +++ b/content/src/content/jcr_root/apps/core/wcm/components/pdfviewer/v1/pdfviewer/clientlibs/site/js/pdfviewer.js @@ -18,7 +18,7 @@ var NS = "cmp"; var IS = "pdfviewer"; - var SDK_URL = "https://documentservices.adobe.com/view-sdk/viewer.js"; + var SDK_URL = "https://acrobatservices.adobe.com/view-sdk/viewer.js"; var SDK_READY_EVENT = "adobe_dc_view_sdk.ready"; var selectors = {