Add <ins> and <del> HTML tags to whitelist

This commit is contained in:
cketti 2017-11-01 19:34:11 +01:00
parent 0a6ef2b70f
commit b51d9d09a3
2 changed files with 10 additions and 1 deletions

View file

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

View file

@ -167,4 +167,13 @@ public class HtmlSanitizerTest {
assertEquals("<html><head></head><body>one<hr>two<hr>three</body></html>", toCompactString(result));
}
@Test
public void shouldKeepInsDelTags() {
String html = "<html><head></head><body><ins>Inserted</ins><del>Deleted</del></body></html>";
Document result = htmlSanitizer.sanitize(html);
assertEquals(html, toCompactString(result));
}
}