Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40081b43 authored by Philip Whitehouse's avatar Philip Whitehouse
Browse files

Allow center tag and test whitelisting of formatting tags

parent 339b1ed8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ public class HtmlSanitizer {

    HtmlSanitizer() {
        Whitelist whitelist = Whitelist.relaxed()
                .addTags("font", "hr", "ins", "del")
                .addTags("font", "hr", "ins", "del", "center")
                .addAttributes("font", "color", "face", "size")
                .addAttributes("table", "align", "background", "bgcolor", "border", "cellpadding", "cellspacing",
                        "width")
+13 −0
Original line number Diff line number Diff line
@@ -200,4 +200,17 @@ public class HtmlSanitizerTest {

        assertEquals("<html><head></head><body></body></html>", toCompactString(result));
    }

    @Test
    public void shouldKeepFormattingTags() {
        String html = "<html><body>" +
                "<center><font face=\"Arial\" color=\"red\" size=\"12\">A</font></center>" +
                "</body></html>";

        Document result = htmlSanitizer.sanitize(html);

        assertEquals("<html><head></head><body>" +
                "<center><font face=\"Arial\" color=\"red\" size=\"12\">A</font></center>" +
                "</body></html>", toCompactString(result));
    }
}