From a059ed595e8e01b6391b00a1fb645667c9aa4428 Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Tue, 1 Oct 2024 19:14:56 +0200 Subject: [PATCH 1/2] #3413 - Redirect Manager: Interface triggers an error because of wrong deprecated resource type (#3416) * #3413 - Redirect Manager: Interface triggers an error because of wrong deprecated resource type --- CHANGELOG.md | 5 +++- .../manage-redirects/clientlibs/app.js | 9 ++++--- .../redirect-row/redirect-row.html | 25 +++++++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/redirect-row/redirect-row.html diff --git a/CHANGELOG.md b/CHANGELOG.md index 60da973c5f..39d4d43e13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,10 +20,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com) - #3420 - Redirect Map Manager - enable Redirect Map Manager in AEM CS (would require a specific - not public yet - AEM CS release version, TBA) - #3429 - UI Widgets - add uniq function to embedded lodash library to resolve issue with composite multifield widget - #3423 - Redirect Manager - status code is not retaining its value in the dialog after authoring +- #3417 - Configurable recursion in Content Sync + +### Fixed +- #3413 - Redirect Manager: Interface triggers an error because of wrong deprecated resource type ## 6.6.4 - 2024-08-14 -- #3417 - Configurable recursion in Content Sync ### Fixed diff --git a/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/clientlibs/app.js b/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/clientlibs/app.js index d15433067e..1779e67bae 100755 --- a/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/clientlibs/app.js +++ b/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/clientlibs/app.js @@ -115,15 +115,18 @@ $.ajax({ url: redirectPath + ".html" }).done(function (trHtml) { + var tr; if (response.isCreate) { var editRedirectTable = $(TABLE_SELECTOR); - var tr = editRedirectTable + tr = editRedirectTable .find("tbody")[0] .appendChild(document.createElement("tr")); - $(tr).replaceWith(trHtml); + tr.id = redirectId; + tr.dataset.path = redirectPath; } else { - $("#" + redirectId).replaceWith(trHtml); + tr = $("#" + redirectId)[0]; } + tr.innerHTML = trHtml; var ui = $(window).adaptTo("foundation-ui"); ui.clearWait(); }); diff --git a/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/redirect-row/redirect-row.html b/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/redirect-row/redirect-row.html new file mode 100644 index 0000000000..304a5e0cfb --- /dev/null +++ b/ui.apps/src/main/content/jcr_root/apps/acs-commons/components/utilities/manage-redirects/redirect-row/redirect-row.html @@ -0,0 +1,25 @@ + + From 4f4f18c8743014452c2a9ae92905c65f8f673db1 Mon Sep 17 00:00:00 2001 From: Bart Date: Tue, 1 Oct 2024 19:32:33 +0200 Subject: [PATCH 2/2] #3438 - Fix bug where duplicate scheme is added to rewritten url value (#3439) Co-authored-by: Bart Thierens --- ...ticReferenceRewriteTransformerFactory.java | 6 ++++-- ...eferenceRewriteTransformerFactoryTest.java | 20 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/bundle/src/main/java/com/adobe/acs/commons/rewriter/impl/StaticReferenceRewriteTransformerFactory.java b/bundle/src/main/java/com/adobe/acs/commons/rewriter/impl/StaticReferenceRewriteTransformerFactory.java index 74f5e71170..8aa04d311f 100644 --- a/bundle/src/main/java/com/adobe/acs/commons/rewriter/impl/StaticReferenceRewriteTransformerFactory.java +++ b/bundle/src/main/java/com/adobe/acs/commons/rewriter/impl/StaticReferenceRewriteTransformerFactory.java @@ -240,9 +240,11 @@ private String handleMatchingPatternAttribute(Pattern pattern, String attrValue) url = prependHostName(url); // Added check to determine whether the existing host has to be replaced if (this.replaceHost) { - int index = attrValue.indexOf("://"); sb.setLength(0); - sb.append(attrValue, 0, index + 1); + if (!url.contains("://")) { + String reuseScheme = attrValue.substring(0, attrValue.indexOf("://") + 1); + sb.append(reuseScheme); + } sb.append(url); } else { m.appendReplacement(sb, Matcher.quoteReplacement(url)); diff --git a/bundle/src/test/java/com/adobe/acs/commons/rewriter/impl/StaticReferenceRewriteTransformerFactoryTest.java b/bundle/src/test/java/com/adobe/acs/commons/rewriter/impl/StaticReferenceRewriteTransformerFactoryTest.java index 74f410ffe5..d0281f14c9 100644 --- a/bundle/src/test/java/com/adobe/acs/commons/rewriter/impl/StaticReferenceRewriteTransformerFactoryTest.java +++ b/bundle/src/test/java/com/adobe/acs/commons/rewriter/impl/StaticReferenceRewriteTransformerFactoryTest.java @@ -20,9 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.only; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.*; import java.util.List; @@ -124,6 +122,12 @@ public void test_with_prefix_and_matching_pattern_and_single_host() throws Excep @Test public void test_with_prefix_and_matching_pattern_and_single_host_and_replace_host() throws Exception { + test_with_prefix_and_matching_pattern_and_single_host_and_replace_host_custom_scheme(null); + test_with_prefix_and_matching_pattern_and_single_host_and_replace_host_custom_scheme("https"); + test_with_prefix_and_matching_pattern_and_single_host_and_replace_host_custom_scheme("http"); + } + + private void test_with_prefix_and_matching_pattern_and_single_host_and_replace_host_custom_scheme(String scheme) throws Exception { MockBundle bundle = new MockBundle(-1); MockComponentContext ctx = new MockComponentContext(bundle); ctx.setProperty("prefixes", new String[] { "/content/dam" }); @@ -131,21 +135,27 @@ public void test_with_prefix_and_matching_pattern_and_single_host_and_replace_ho ctx.setProperty("host.pattern", "static.host.com"); ctx.setProperty("matchingPatterns", "img:src;(\\/content\\/dam\\/.+?\\.(png|jpg))"); ctx.setProperty("replaceHost", true); + if (scheme != null) { + ctx.setProperty("host.scheme", scheme); + } StaticReferenceRewriteTransformerFactory factory = new StaticReferenceRewriteTransformerFactory(); factory.activate(ctx); + reset(handler); Transformer transformer = factory.createTransformer(); transformer.setContentHandler(handler); AttributesImpl imageWithJustSrc = new AttributesImpl(); - imageWithJustSrc.addAttribute(null, "src", null, "CDATA", "https://www.host.com/content/dam/flower.jpg"); + String inputUrl = "https://www.host.com/content/dam/flower.jpg"; + imageWithJustSrc.addAttribute(null, "src", null, "CDATA", inputUrl); transformer.startElement(null, "img", null, imageWithJustSrc); verify(handler, only()).startElement(isNull(), eq("img"), isNull(), attributesCaptor.capture()); List values = attributesCaptor.getAllValues(); - assertEquals("https://static.host.com/content/dam/flower.jpg", values.get(0).getValue(0)); + String expectedScheme = scheme == null ? inputUrl.substring(0, inputUrl.indexOf("://")) : scheme; + assertEquals(expectedScheme + "://static.host.com/content/dam/flower.jpg", values.get(values.size() - 1).getValue(0)); } @Test