1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-02-21 21:57:19 +00:00

Fixed namespace check

This commit is contained in:
M66B 2022-04-30 20:36:34 +02:00
parent 999c2bb019
commit 21b8264e3a

View file

@ -150,6 +150,7 @@ public class HtmlHelper {
private static final int TRACKING_PIXEL_SURFACE = 25; // pixels private static final int TRACKING_PIXEL_SURFACE = 25; // pixels
private static final float[] HEADING_SIZES = {1.5f, 1.4f, 1.3f, 1.2f, 1.1f, 1f}; private static final float[] HEADING_SIZES = {1.5f, 1.4f, 1.3f, 1.2f, 1.1f, 1f};
private static final String LINE = "----------------------------------------"; private static final String LINE = "----------------------------------------";
private static final String W3NS = "http://www.w3.org/";
private static final HashMap<String, Integer> x11ColorMap = new HashMap<>(); private static final HashMap<String, Integer> x11ColorMap = new HashMap<>();
@ -1564,19 +1565,22 @@ public class HtmlHelper {
// <o:p>&nbsp;</o:p></span> // <o:p>&nbsp;</o:p></span>
// Default XHTML namespace: http://www.w3.org/1999/xhtml // Default XHTML namespace: http://www.w3.org/1999/xhtml
// https://developer.mozilla.org/en-US/docs/Related/IMSC/Namespaces
String ns = null; String ns = null;
for (Element h : parsed.select("html")) for (Element h : parsed.select("html"))
for (Attribute a : h.attributes()) { for (Attribute a : h.attributes()) {
String key = a.getKey(); String key = a.getKey();
String value = a.getValue(); String value = a.getValue();
if (value != null && if ("xmlns".equals(key) && value.startsWith(W3NS)) {
key.startsWith("xmlns:") && ns = key;
value.startsWith("http://www.w3.org/")) { break;
} else if (key.startsWith("xmlns:") && value.startsWith(W3NS)) {
ns = key.split(":")[1]; ns = key.split(":")[1];
break; break;
} }
} }
for (Element e : parsed.select("*")) { for (Element e : parsed.select("*")) {
String tag = e.tagName(); String tag = e.tagName();
if (tag.contains(":")) { if (tag.contains(":")) {
@ -1595,6 +1599,17 @@ public class HtmlHelper {
Log.i("Removed tag=" + tag); Log.i("Removed tag=" + tag);
} }
} }
String xmlns = e.attr("xmlns");
if (!TextUtils.isEmpty(xmlns) && !xmlns.startsWith(W3NS)) {
if (display_hidden) {
String style = e.attr("style");
e.attr("style", mergeStyles(style, "text-decoration:line-through;"));
} else {
e.remove();
Log.i("Removed tag=" + tag + "xmlns=" + xmlns);
}
}
} }
} }