From 52157cfd4242bb4aecc4ef937b09fafee46cb4eb Mon Sep 17 00:00:00 2001 From: rcyarrapothu Date: Wed, 2 Feb 2022 13:59:13 -0600 Subject: [PATCH] ZBUG-1932: Upgrading owasp-java-html-sanitizer version --- store/build.xml | 2 +- store/ivy.xml | 4 ++- .../cs/html/owasp/OwaspHtmlSanitizerTest.java | 28 +++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/store/build.xml b/store/build.xml index cf0044c2bad..78639275f72 100644 --- a/store/build.xml +++ b/store/build.xml @@ -289,7 +289,7 @@ - + diff --git a/store/ivy.xml b/store/ivy.xml index 99edc9d918f..c593c906461 100644 --- a/store/ivy.xml +++ b/store/ivy.xml @@ -44,7 +44,7 @@ - + @@ -138,5 +138,7 @@ + + diff --git a/store/src/java-test/com/zimbra/cs/html/owasp/OwaspHtmlSanitizerTest.java b/store/src/java-test/com/zimbra/cs/html/owasp/OwaspHtmlSanitizerTest.java index 12f0db7e7ef..dc91187fbff 100644 --- a/store/src/java-test/com/zimbra/cs/html/owasp/OwaspHtmlSanitizerTest.java +++ b/store/src/java-test/com/zimbra/cs/html/owasp/OwaspHtmlSanitizerTest.java @@ -42,6 +42,7 @@ import com.zimbra.cs.mime.ParsedMessage; import com.zimbra.cs.servlet.ZThreadLocal; import com.zimbra.cs.util.ZTestWatchman; +import org.owasp.html.Encoding; public class OwaspHtmlSanitizerTest { @@ -731,4 +732,31 @@ public void testBugZCS10594() throws Exception { String output = "
First Line

Second Line
"; Assert.assertTrue("Verification failed: Failed to include media queries.", output.equals(result.trim())); } + + @Test + public void testBug1932ShouldReturnSameUrlAfterSanitizing_1() throws Exception { + String url = "https://google.com/?page=red.blue&num_ar=abcd123456&orgAcronyme=abc12"; + String html = ""+url+""; + String result = new OwaspHtmlSanitizer(html, true, null).sanitize(); + //&num should not be converted to # + Assert.assertTrue(Encoding.decodeHtml(result).contains(url)); + } + + @Test + public void testBug1932ShouldReturnSameUrlAfterSanitizing_2() throws Exception { + String url = "https://google.com/?page=red.blue&numero_num=10&Integral_int=20"; + String html = ""+url+""; + String result = new OwaspHtmlSanitizer(html, true, null).sanitize(); + //&numero and &Integral should not be converted to № and ∫ + Assert.assertTrue(Encoding.decodeHtml(result).contains(url)); + } + + @Test + public void testBug1932ShouldReturnSameUrlAfterSanitizing_3() throws Exception { + String url = "https://google.com/?account=2&order_id=125"; + String html = ""+url+""; + String result = new OwaspHtmlSanitizer(html, true, null).sanitize(); + //&order should not be converted to ℴ + Assert.assertTrue(Encoding.decodeHtml(result).contains(url)); + } }