mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-26 01:36:55 +00:00
Remove scripts from original messages
This commit is contained in:
parent
3ac49cb2a5
commit
d1c1ebfe01
1 changed files with 11 additions and 0 deletions
|
@ -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 a new issue