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:
parent
8c5ecbc965
commit
661f2e3732
1 changed files with 19 additions and 1 deletions
|
@ -1430,14 +1430,32 @@ public class HtmlHelper {
|
||||||
sb.append("data:image/png;base64,");
|
sb.append("data:image/png;base64,");
|
||||||
sb.append(Base64.encodeToString(bos.toByteArray(), Base64.NO_WRAP));
|
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
|
// Images
|
||||||
for (Element img : document.select("img")) {
|
for (Element img : document.select("img")) {
|
||||||
img.removeAttr("x-tracking");
|
img.removeAttr("x-tracking");
|
||||||
String src = img.attr("src");
|
String src = img.attr("src");
|
||||||
if (TextUtils.isEmpty(src))
|
if (TextUtils.isEmpty(src))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Uri uri = Uri.parse(src);
|
||||||
|
String host = uri.getHost();
|
||||||
|
if (host == null || hosts.contains(host))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (isTrackingPixel(img) ||
|
if (isTrackingPixel(img) ||
|
||||||
(disconnect_images && DisconnectBlacklist.isTracking(Uri.parse(src).getHost()))) {
|
(disconnect_images && DisconnectBlacklist.isTracking(host))) {
|
||||||
img.attr("src", sb.toString());
|
img.attr("src", sb.toString());
|
||||||
img.attr("alt", context.getString(R.string.title_legend_tracking_pixel));
|
img.attr("alt", context.getString(R.string.title_legend_tracking_pixel));
|
||||||
img.attr("height", "24");
|
img.attr("height", "24");
|
||||||
|
|
Loading…
Reference in a new issue