From 4376f9bc2252e8a97a95b259a9115a419d45b9b1 Mon Sep 17 00:00:00 2001 From: Philip Whitehouse Date: Mon, 22 Jan 2018 13:11:54 +0000 Subject: [PATCH] Add support for image-maps --- .../fsck/k9/message/html/HtmlSanitizer.java | 6 ++++- .../k9/message/html/HtmlSanitizerTest.java | 22 +++++++++++++++++++ 2 files changed, 27 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 2b197857a..1707f7c9e 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", "hr", "ins", "del", "center") + .addTags("font", "hr", "ins", "del", "center", "map", "area") .addAttributes("font", "color", "face", "size") .addAttributes("table", "align", "background", "bgcolor", "border", "cellpadding", "cellspacing", "width") @@ -24,6 +24,10 @@ public class HtmlSanitizer { .addAttributes("td", "align", "bgcolor", "colspan", "headers", "height", "nowrap", "rowspan", "scope", "valign", "width") + .addAttributes("map", "name") + .addAttributes("area", "shape", "coords", "href", "alt") + .addProtocols("area", "href", "http", "https") + .addAttributes("img", "usemap") .addAttributes(":all", "class", "style", "id") .addProtocols("img", "src", "http", "https", "cid", "data") .addProtocols("a", "href", "tel", "sip", "bitcoin", "ethereum", "rtsp"); 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 3e9f6bf9c..71efe874f 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 @@ -177,6 +177,28 @@ public class HtmlSanitizerTest { assertEquals(html, toCompactString(result)); } + @Test + public void shouldKeepMapAreaTags() { + String html = "\n" + + " \"Sun\"\n" + + " \"Mercury\"\n" + + " \"Venus\"\n" + + ""; + + Document result = htmlSanitizer.sanitize(html); + + assertEquals(html, toCompactString(result)); + } + + @Test + public void shouldKeepImgUsemap() { + String html = ""; + + Document result = htmlSanitizer.sanitize(html); + + assertEquals(html, toCompactString(result)); + } + @Test public void shouldKeepWhitelistedElementsInHeadAndSkipTheRest() { String html = "" +