From 7b532e0f9810250f92eedcadabf8a04308ed9768 Mon Sep 17 00:00:00 2001 From: log2akshat Date: Tue, 1 Jun 2021 17:12:19 +0530 Subject: [PATCH 1/2] ZCS-10594: Adding unit test for media queries not get removed from the sty;le sheet. --- .../com/zimbra/cs/html/owasp/OwaspHtmlSanitizerTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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 3078245a137..f862b48845c 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 @@ -718,4 +718,12 @@ public void testBugTSS18004() throws Exception { // check that the extra double quotes are removed Assert.assertTrue("Verification failed: Failed to remove extra double quotes.", output.equals(result.trim())); } + + @Test + public void testBugZCS10594() throws Exception { + String malformedHtml = "
First Line

Second Line
"; + String result = new OwaspHtmlSanitizer(malformedHtml, true, null).sanitize(true); + String output = "
First Line

Second Line
"; + Assert.assertTrue("Verification failed: Failed to include media queries.", output.equals(result.trim())); + } } From 5ed799df46bdad17906801ef5475961d1eba8197 Mon Sep 17 00:00:00 2001 From: log2akshat Date: Wed, 2 Jun 2021 13:20:15 +0530 Subject: [PATCH 2/2] Adding test case for TSS-18004 --- .../cs/html/owasp/OwaspHtmlSanitizerTest.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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 f862b48845c..8e38a6ce276 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 @@ -707,14 +707,18 @@ public void testZBUG1215() throws Exception { @Test public void testBugTSS18004() throws Exception { - String malformedHtml = "

" - + "Hello h" - + "ave a nice day." - + "

"; - String result = new OwaspHtmlSanitizer(malformedHtml, true, null).cleanMalformedHtml(malformedHtml, true); - String output = "

" - + "Hello h" - + "ave a nice day.

"; + String malformedHtml = "

This is a heading

"; + String result = new OwaspHtmlSanitizer(malformedHtml, true, null).sanitize(false); + String output = "

This is a heading

"; + // check that the extra double quotes are removed + Assert.assertTrue("Verification failed: Failed to remove extra double quotes.", output.equals(result.trim())); + } + + @Test + public void testBugTSS18004_1() throws Exception { + String malformedHtml = "

This is a heading

"; + String result = new OwaspHtmlSanitizer(malformedHtml, true, null).sanitize(false); + String output = "

This is a heading

"; // check that the extra double quotes are removed Assert.assertTrue("Verification failed: Failed to remove extra double quotes.", output.equals(result.trim())); }