1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-26 17:57:16 +00:00

Consider images from same domain not as tracking images

This commit is contained in:
M66B 2020-08-03 20:05:52 +02:00
parent 8c5ecbc965
commit 661f2e3732

View file

@ -1430,14 +1430,32 @@ public class HtmlHelper {
sb.append("data:image/png;base64,");
sb.append(Base64.encodeToString(bos.toByteArray(), Base64.NO_WRAP));
// Build list of allowed hosts
List<String> hosts = new ArrayList<>();
for (Element img : document.select("img")) {
String src = img.attr("src");
if (!TextUtils.isEmpty(src) && !isTrackingPixel(img)) {
Uri uri = Uri.parse(img.attr("src"));
String host = uri.getHost();
if (host != null && !hosts.contains(host))
hosts.add(host);
}
}
// Images
for (Element img : document.select("img")) {
img.removeAttr("x-tracking");
String src = img.attr("src");
if (TextUtils.isEmpty(src))
continue;
Uri uri = Uri.parse(src);
String host = uri.getHost();
if (host == null || hosts.contains(host))
continue;
if (isTrackingPixel(img) ||
(disconnect_images && DisconnectBlacklist.isTracking(Uri.parse(src).getHost()))) {
(disconnect_images && DisconnectBlacklist.isTracking(host))) {
img.attr("src", sb.toString());
img.attr("alt", context.getString(R.string.title_legend_tracking_pixel));
img.attr("height", "24");