Skip to content

Commit

Permalink
TSS-18300/ZCS-10506: Addressing review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
log2akshat committed Apr 22, 2021
1 parent 9d475b3 commit 3823214
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion build-common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@
<exclude name="**/cs/redolog/op/CreateMessageTest.java"/>
<exclude name="**/cs/service/mail/SearchActionTest.java"/>
<exclude name="**/cs/filter/RuleManagerWithCustomActionFilterTest.java"/>
<exclude name="**/html/owasp/OwaspHtmlSanitizerTest.java"/>
</fileset>
</batchtest>
</junit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,6 @@ public void testBugTSS18004() throws Exception {
+ "style=\"font-size:11pt;font-family:Arial;font-variant-ligatures:normal;font-variant-east-asian:normal;font-variant-position:normal;vertical-align:baseline\">ave\n"
+ "a nice day.</span></p>";
// check that the extra double quotes are removed
Assert.assertTrue(output.equals(result.trim()));
Assert.assertTrue("Verification failed: Failed to remove extra double quotes.", output.equals(result.trim()));
}
}
12 changes: 6 additions & 6 deletions store/src/java/com/zimbra/cs/html/owasp/OwaspHtmlSanitizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ public String sanitize() throws UnsupportedEncodingException {
return processSanitization(true).toString();
}

public String sanitize(boolean cleanData) throws UnsupportedEncodingException {
return processSanitization(cleanData).toString();
public String sanitize(boolean cleanMalformedHtml) throws UnsupportedEncodingException {
return processSanitization(cleanMalformedHtml).toString();
}

private StringBuilder processSanitization(boolean cleanData) throws UnsupportedEncodingException {
private StringBuilder processSanitization(boolean cleanMalformedHtml) throws UnsupportedEncodingException {
OwaspThreadLocal threadLocalInstance = new OwaspThreadLocal();
threadLocalInstance.setVHost(vHost);
OwaspHtmlSanitizer.zThreadLocal.set(threadLocalInstance);
Expand All @@ -93,14 +93,14 @@ public void handle(final String x) {
instantiatePolicy();
final Policy policy = POLICY_DEFINITION.apply(new StyleTagReceiver(renderer));
// run the html through the sanitizer
runSanitizer(html, policy, cleanData);
runSanitizer(html, policy, cleanMalformedHtml);
// return the resulting HTML from the builder
OwaspHtmlSanitizer.zThreadLocal.remove();
return htmlBuilder;
}

private void runSanitizer(String str, Policy policy, boolean cleanData) throws UnsupportedEncodingException {
if (cleanData) {
private void runSanitizer(String str, Policy policy, boolean cleanMalformedHtml) throws UnsupportedEncodingException {
if (cleanMalformedHtml) {
HtmlSanitizer.sanitize(cleanMalformedHtml(str, false), policy);
} else {
HtmlSanitizer.sanitize(str, policy);
Expand Down

0 comments on commit 3823214

Please sign in to comment.