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

Commit 620f62e3 authored by Philip Whitehouse's avatar Philip Whitehouse
Browse files

Whitelist the dir attribute to improve internationalisation

parent 0c620944
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ public class HtmlSanitizer {
                .addAttributes("area", "shape", "coords", "href", "alt")
                .addProtocols("area", "href", "http", "https")
                .addAttributes("img", "usemap")
                .addAttributes(":all", "class", "style", "id")
                .addAttributes(":all", "class", "style", "id", "dir")
                .addProtocols("img", "src", "http", "https", "cid", "data")
                .addProtocols("a", "href", "tel", "sip", "bitcoin", "ethereum", "rtsp");

+11 −0
Original line number Diff line number Diff line
@@ -264,4 +264,15 @@ public class HtmlSanitizerTest {
                "<a href=\"rtsp://example.com/media.mp4\">RTSP</a>" +
                "</body></html>", toCompactString(result));
    }

    @Test
    public void shouldKeepDirAttribute() {
        String html = "<html><head></head><body>" +
                "<table><tbody><tr><td dir=\"rtl\"></td></tr></tbody></table>" +
                "</body></html>";

        Document result = htmlSanitizer.sanitize(html);

        assertEquals(html, toCompactString(result));
    }
}