mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-03 07:36:31 +02:00
Mark tracking images
This commit is contained in:
@@ -103,7 +103,7 @@ public class ActivityEml extends ActivityBase {
|
||||
result.parts = HtmlHelper.fromHtml(sb.toString());
|
||||
|
||||
result.html = parts.getHtml(context);
|
||||
result.body = HtmlHelper.fromHtml(HtmlHelper.sanitize(result.html, true));
|
||||
result.body = HtmlHelper.fromHtml(HtmlHelper.sanitize(context, result.html, true));
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
mmessage.writeTo(bos);
|
||||
|
||||
@@ -1653,7 +1653,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
final boolean show_quotes = properties.getValue("quotes", message.id);
|
||||
final boolean show_images = properties.getValue("images", message.id);
|
||||
|
||||
return HtmlHelper.fromHtml(HtmlHelper.sanitize(body, show_quotes), new Html.ImageGetter() {
|
||||
return HtmlHelper.fromHtml(HtmlHelper.sanitize(context, body, show_quotes), new Html.ImageGetter() {
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
Drawable image = HtmlHelper.decodeImage(source, context, message.id, show_images);
|
||||
|
||||
@@ -2336,7 +2336,7 @@ public class FragmentCompose extends FragmentBase {
|
||||
Spanned spannedReference = null;
|
||||
File refFile = EntityMessage.getRefFile(context, id);
|
||||
if (refFile.exists()) {
|
||||
String quote = HtmlHelper.sanitize(Helper.readText(refFile), true);
|
||||
String quote = HtmlHelper.sanitize(context, Helper.readText(refFile), true);
|
||||
Spanned spannedQuote = HtmlHelper.fromHtml(quote,
|
||||
new Html.ImageGetter() {
|
||||
@Override
|
||||
|
||||
@@ -65,7 +65,7 @@ public class HtmlHelper {
|
||||
private static final List<String> heads = Arrays.asList("h1", "h2", "h3", "h4", "h5", "h6", "p", "table", "ol", "ul", "br", "hr");
|
||||
private static final List<String> tails = Arrays.asList("h1", "h2", "h3", "h4", "h5", "h6", "p", "ol", "ul", "li");
|
||||
|
||||
static String sanitize(String html, boolean showQuotes) {
|
||||
static String sanitize(Context context, String html, boolean showQuotes) {
|
||||
final Document document = Jsoup.parse(Jsoup.clean(html, Whitelist
|
||||
.relaxed()
|
||||
.addTags("hr")
|
||||
@@ -137,9 +137,14 @@ public class HtmlHelper {
|
||||
|
||||
// Images
|
||||
for (Element img : document.select("img")) {
|
||||
String src = img.attr("src");
|
||||
String alt = img.attr("alt");
|
||||
String height = img.attr("height").trim();
|
||||
String width = img.attr("width").trim();
|
||||
|
||||
Element div = document.createElement("div");
|
||||
|
||||
Uri uri = Uri.parse(img.attr("src"));
|
||||
Uri uri = Uri.parse(src);
|
||||
if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())) {
|
||||
boolean linked = false;
|
||||
for (Element parent : img.parents())
|
||||
@@ -160,12 +165,17 @@ public class HtmlHelper {
|
||||
}
|
||||
}
|
||||
|
||||
String alt = img.attr("alt");
|
||||
if (!TextUtils.isEmpty(alt)) {
|
||||
div.appendElement("br");
|
||||
div.appendElement("em").text(alt);
|
||||
}
|
||||
|
||||
// Tracking image
|
||||
if ("1".equals(height) && "1".equals(width) && !TextUtils.isEmpty(src)) {
|
||||
div.appendElement("br");
|
||||
div.appendElement("strong").text(context.getString(R.string.title_hint_tracking_image));
|
||||
}
|
||||
|
||||
img.replaceWith(div);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user