Browse Source

Use Jsoup cleaner

main
M66B 6 years ago
parent
commit
8bcc1b3163
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      app/src/main/java/eu/faircode/email/HtmlHelper.java

+ 3
- 3
app/src/main/java/eu/faircode/email/HtmlHelper.java View File

@ -31,6 +31,7 @@ import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.jsoup.nodes.TextNode;
import org.jsoup.safety.Whitelist;
import org.jsoup.select.NodeTraversor;
import org.jsoup.select.NodeVisitor;
@ -115,14 +116,13 @@ public class HtmlHelper implements NodeVisitor {
public static String sanitize(Context context, String html, boolean reply) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
Document document = Jsoup.parse(html);
if (prefs.getBoolean("sanitize", false)) {
Document document = Jsoup.parse(html);
HtmlHelper visitor = new HtmlHelper(context, reply);
NodeTraversor.traverse(visitor, document.body());
return visitor.toString();
} else {
document.getElementsByTag("style").remove();
document.select("[style]").removeAttr("style");
Document document = Jsoup.parse(Jsoup.clean(html, Whitelist.relaxed()));
for (Element tr : document.select("tr"))
tr.after("<br>");
return document.body().html();


Loading…
Cancel
Save