mirror of https://github.com/M66B/FairEmail.git
Remove scripts from original messages
This commit is contained in:
parent
3ac49cb2a5
commit
d1c1ebfe01
|
@ -33,6 +33,7 @@ import android.text.TextUtils;
|
|||
import android.util.Base64;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Attribute;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.nodes.Node;
|
||||
|
@ -75,6 +76,7 @@ public class HtmlHelper {
|
|||
|
||||
Document document = Jsoup.parse(html);
|
||||
|
||||
// Remove tracking pixels
|
||||
for (Element img : document.select("img")) {
|
||||
String src = img.attr("src");
|
||||
String height = img.attr("height").trim();
|
||||
|
@ -83,6 +85,15 @@ public class HtmlHelper {
|
|||
img.removeAttr("src");
|
||||
}
|
||||
|
||||
// Remove Javascript
|
||||
for (Element e : document.select("*"))
|
||||
for (Attribute a : e.attributes())
|
||||
if (a.getValue().trim().toLowerCase().startsWith("javascript:"))
|
||||
e.removeAttr(a.getKey());
|
||||
|
||||
// Remove scripts
|
||||
document.select("script").remove();
|
||||
|
||||
return document.outerHtml();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue