From c93c6c3ac13055141a85955b25e18b0c46f29c3e Mon Sep 17 00:00:00 2001 From: Justin Edelson Date: Fri, 11 Sep 2015 15:08:57 -0400 Subject: [PATCH] removing workaround for 5.6.1 bug. fixes #530. --- .../adobe/acs/commons/xss/XSSFunctions.java | 27 +------------------ .../acs/commons/xss/XSSFunctionsTest.java | 16 +++-------- 2 files changed, 4 insertions(+), 39 deletions(-) diff --git a/bundle/src/main/java/com/adobe/acs/commons/xss/XSSFunctions.java b/bundle/src/main/java/com/adobe/acs/commons/xss/XSSFunctions.java index 62db5c787c..43c12caa00 100644 --- a/bundle/src/main/java/com/adobe/acs/commons/xss/XSSFunctions.java +++ b/bundle/src/main/java/com/adobe/acs/commons/xss/XSSFunctions.java @@ -104,32 +104,7 @@ public static CharSequence filterHTML(XSSAPI xssAPI, String source) { */ @Function public static CharSequence getValidHref(XSSAPI xssAPI, String source) { - try { - final String testHtml = LINK_PREFIX + mangleNamespaces(source) + LINK_SUFFIX; - - final String safeHtml = xssAPI.filterHTML(testHtml); - return safeHtml.substring(LINK_PREFIX.length(), safeHtml.length() - LINK_SUFFIX.length()); - } catch (final Exception e) { - return ""; - } - } - - private static String mangleNamespaces(String absPath) { - if (absPath != null && absPath.contains(MANGLE_NAMESPACE_OUT_SUFFIX)) { - final Matcher m = MANGLE_NAMESPACE_PATTERN.matcher(absPath); - - final StringBuffer buf = new StringBuffer(); - while (m.find()) { - final String replacement = MANGLE_NAMESPACE_IN_PREFIX + m.group(1) + MANGLE_NAMESPACE_IN_SUFFIX; - m.appendReplacement(buf, replacement); - } - - m.appendTail(buf); - - absPath = buf.toString(); - } - - return absPath; + return xssAPI.getValidHref(source); } private XSSFunctions() { diff --git a/bundle/src/test/java/com/adobe/acs/commons/xss/XSSFunctionsTest.java b/bundle/src/test/java/com/adobe/acs/commons/xss/XSSFunctionsTest.java index d5806fa8d1..a556adbe7c 100644 --- a/bundle/src/test/java/com/adobe/acs/commons/xss/XSSFunctionsTest.java +++ b/bundle/src/test/java/com/adobe/acs/commons/xss/XSSFunctionsTest.java @@ -71,21 +71,11 @@ public void testFilterHTML() { } @Test - public void testGetValidHrefUnMangled() { + public void testGetValidHref() { final String test = "/content/foo.html"; - final String expectedHtml = ""; - when(xssAPI.filterHTML(expectedHtml)).thenReturn(expectedHtml); + when(xssAPI.getValidHref(test)).thenReturn(test); XSSFunctions.getValidHref(xssAPI, test); - verify(xssAPI, only()).filterHTML(expectedHtml); - } - - @Test - public void testGetValidHrefMangled() { - final String test = "/content/foo/jcr:content/bar.html"; - final String expectedHtml = ""; - when(xssAPI.filterHTML(expectedHtml)).thenReturn(expectedHtml); - XSSFunctions.getValidHref(xssAPI, test); - verify(xssAPI, only()).filterHTML(expectedHtml); + verify(xssAPI, only()).getValidHref(test); } @Test