From 77f821cbbe5b6e01742fd8ba8f556a735b0e818a Mon Sep 17 00:00:00 2001 From: cketti Date: Wed, 25 Oct 2017 04:13:52 +0200 Subject: [PATCH] Add
to HtmlSanitizer whitelist --- .../java/com/fsck/k9/message/html/HtmlSanitizer.java | 2 +- .../java/com/fsck/k9/message/html/HtmlSanitizerTest.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/k9mail/src/main/java/com/fsck/k9/message/html/HtmlSanitizer.java b/k9mail/src/main/java/com/fsck/k9/message/html/HtmlSanitizer.java index 1b9cbf737..fc74be844 100644 --- a/k9mail/src/main/java/com/fsck/k9/message/html/HtmlSanitizer.java +++ b/k9mail/src/main/java/com/fsck/k9/message/html/HtmlSanitizer.java @@ -13,7 +13,7 @@ public class HtmlSanitizer { HtmlSanitizer() { Whitelist whitelist = Whitelist.relaxed() - .addTags("font") + .addTags("font", "hr") .addAttributes("table", "align", "bgcolor", "border", "cellpadding", "cellspacing", "width") .addAttributes(":all", "class", "style", "id") .addProtocols("img", "src", "http", "https", "cid", "data"); diff --git a/k9mail/src/test/java/com/fsck/k9/message/html/HtmlSanitizerTest.java b/k9mail/src/test/java/com/fsck/k9/message/html/HtmlSanitizerTest.java index 23714a4e8..f4b86c2a1 100644 --- a/k9mail/src/test/java/com/fsck/k9/message/html/HtmlSanitizerTest.java +++ b/k9mail/src/test/java/com/fsck/k9/message/html/HtmlSanitizerTest.java @@ -158,4 +158,13 @@ public class HtmlSanitizerTest { "Hmailserver service shutdown:Ok" + "", toCompactString(result)); } + + @Test + public void shouldKeepHrTags() throws Exception { + String html = "one
two
three"; + + Document result = htmlSanitizer.sanitize(html); + + assertEquals("one
two
three", toCompactString(result)); + } }