Merge pull request #2862 from k9mail/GH-2856_fix_horizontal_lines

Add <hr> to HtmlSanitizer whitelist
This commit is contained in:
cketti 2017-10-28 00:12:06 +02:00 committed by GitHub
commit 23b903e7d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -13,7 +13,7 @@ public class HtmlSanitizer {
HtmlSanitizer() { HtmlSanitizer() {
Whitelist whitelist = Whitelist.relaxed() Whitelist whitelist = Whitelist.relaxed()
.addTags("font") .addTags("font", "hr")
.addAttributes("table", "align", "bgcolor", "border", "cellpadding", "cellspacing", "width") .addAttributes("table", "align", "bgcolor", "border", "cellpadding", "cellspacing", "width")
.addAttributes(":all", "class", "style", "id") .addAttributes(":all", "class", "style", "id")
.addProtocols("img", "src", "http", "https", "cid", "data"); .addProtocols("img", "src", "http", "https", "cid", "data");

View file

@ -158,4 +158,13 @@ public class HtmlSanitizerTest {
"<tr><td>Hmailserver service shutdown:</td><td>Ok</td></tr>" + "<tr><td>Hmailserver service shutdown:</td><td>Ok</td></tr>" +
"</tbody></table></body></html>", toCompactString(result)); "</tbody></table></body></html>", toCompactString(result));
} }
@Test
public void shouldKeepHrTags() throws Exception {
String html = "<html><head></head><body>one<hr>two<hr />three</body></html>";
Document result = htmlSanitizer.sanitize(html);
assertEquals("<html><head></head><body>one<hr>two<hr>three</body></html>", toCompactString(result));
}
} }