Process HTML font

This commit is contained in:
M66B 2019-09-25 12:48:02 +02:00
parent 1d1b9f084a
commit 8e245517f3
1 changed files with 12 additions and 2 deletions

View File

@ -136,7 +136,7 @@ public class HtmlHelper {
}
Whitelist whitelist = Whitelist.relaxed()
.addTags("hr", "abbr", "big")
.addTags("hr", "abbr", "big", "font")
.removeTags("col", "colgroup", "thead", "tbody")
.removeAttributes("table", "width")
.removeAttributes("td", "colspan", "rowspan", "width")
@ -144,12 +144,22 @@ public class HtmlHelper {
.addProtocols("img", "src", "cid")
.addProtocols("img", "src", "data");
if (text_color)
whitelist.addAttributes(":all", "style");
whitelist
.addAttributes(":all", "style")
.addAttributes("font", "color");
final Document document = new Cleaner(whitelist).clean(parsed);
boolean dark = Helper.isDarkTheme(context);
// Font
for (Element font : document.select("font")) {
String color = font.attr("color");
font.removeAttr("color");
font.attr("style", "color:" + color + ";");
font.tagName("span");
}
// Sanitize span styles
for (Element span : document.select("*")) {
String style = span.attr("style");