Remove scripts from original messages

This commit is contained in:
M66B 2019-03-10 19:39:17 +00:00
parent 3ac49cb2a5
commit d1c1ebfe01
1 changed files with 11 additions and 0 deletions

View File

@ -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();
}