diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 5e9fda0658..c593fdf90f 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -1461,7 +1461,7 @@ public class AdapterMessage extends RecyclerView.Adapter hosts = new ArrayList<>(); @@ -505,6 +507,7 @@ public class HtmlHelper { // Images for (Element img : document.select("img")) { + img.removeAttr("tracking"); String src = img.attr("src"); if (!TextUtils.isEmpty(src) && isTrackingPixel(img)) { Uri uri = Uri.parse(img.attr("src")); @@ -514,7 +517,8 @@ public class HtmlHelper { img.attr("alt", context.getString(R.string.title_legend_tracking_pixel)); img.attr("height", "24"); img.attr("width", "24"); - img.attr("style", "display: block !important;"); + img.attr("style", "display:block !important; width:24px !important; height:24px !important;"); + img.attr("tracking", "true"); } } } @@ -534,7 +538,7 @@ public class HtmlHelper { } } - static void embedImages(Context context, long id, Document document) throws IOException { + static void embedInlineImages(Context context, long id, Document document) throws IOException { DB db = DB.getInstance(context); for (Element img : document.select("img")) { String src = img.attr("src"); @@ -552,7 +556,7 @@ public class HtmlHelper { sb.append("data:"); sb.append(attachment.type); sb.append(";base64,"); - sb.append(Base64.encodeToString(bytes, Base64.DEFAULT)); + sb.append(Base64.encodeToString(bytes, Base64.NO_WRAP)); img.attr("src", sb.toString()); } diff --git a/app/src/main/java/eu/faircode/email/ImageHelper.java b/app/src/main/java/eu/faircode/email/ImageHelper.java index 9fc01b1fc5..f997d690cf 100644 --- a/app/src/main/java/eu/faircode/email/ImageHelper.java +++ b/app/src/main/java/eu/faircode/email/ImageHelper.java @@ -234,7 +234,7 @@ class ImageHelper { } // Data URI - if (data && (show || inline)) + if (data && (show || inline || a.tracking)) try { Drawable d = getDataDrawable(context, a.source); if (view != null) @@ -459,6 +459,7 @@ class ImageHelper { private String source; private int width = 0; private int height = 0; + private boolean tracking = false; // Encapsulate some ugliness @@ -469,24 +470,25 @@ class ImageHelper { int pos = source.substring(0, source.length() - 3).lastIndexOf("###"); if (pos > 0) { int x = source.indexOf("x", pos + 3); - if (x > 0) + int s = source.indexOf(":", pos + 3); + if (x > 0 && s > x) try { this.width = Integer.parseInt(source.substring(pos + 3, x)); - this.height = Integer.parseInt(source.substring(x + 1, source.length() - 3)); + this.height = Integer.parseInt(source.substring(x + 1, s)); + this.tracking = Boolean.parseBoolean(source.substring(s + 1, source.length() - 3)); this.source = source.substring(0, pos); } catch (NumberFormatException ex) { Log.e(ex); - this.width = 0; - this.height = 0; } } } } - AnnotatedSource(String source, int width, int height) { + AnnotatedSource(String source, int width, int height, boolean tracking) { this.source = source; this.width = width; this.height = height; + this.tracking = tracking; } public String getSource() { @@ -496,7 +498,7 @@ class ImageHelper { String getAnnotated() { return (width == 0 && height == 0 ? source - : source + "###" + width + "x" + height + "###"); + : source + "###" + width + "x" + height + ":" + tracking + "###"); } } }