Refactoring

pull/187/head
M66B 4 years ago
parent f21a133902
commit 8babc79a03

@ -1491,7 +1491,7 @@ public class HtmlHelper {
List<String> hosts = new ArrayList<>();
for (Element img : document.select("img")) {
String src = img.attr("src");
if (!TextUtils.isEmpty(src) && !isTrackingPixel(img)) {
if (!TextUtils.isEmpty(src) && !isTrackingPixel(img, disconnect_images)) {
Uri uri = Uri.parse(img.attr("src"));
String host = uri.getHost();
if (host != null && !hosts.contains(host))
@ -1525,8 +1525,7 @@ public class HtmlHelper {
continue;
}
if (isTrackingPixel(img) ||
(disconnect_images && DisconnectBlacklist.isTracking(host))) {
if (isTrackingPixel(img, disconnect_images)) {
img.attr("src", sb.toString());
img.attr("alt", context.getString(R.string.title_legend_tracking_pixel));
img.attr("height", "24");
@ -1537,14 +1536,19 @@ public class HtmlHelper {
}
}
private static boolean isTrackingPixel(Element img) {
private static boolean isTrackingPixel(Element img, boolean disconnect_images) {
String src = img.attr("src");
if (!TextUtils.isEmpty(src))
try {
Uri uri = Uri.parse(src);
String host = uri.getHost();
if (!TextUtils.isEmpty(host) && TRACKING_HOSTS.contains(host))
return true;
if (!TextUtils.isEmpty(host)) {
if (TRACKING_HOSTS.contains(host))
return true;
if (disconnect_images &&
DisconnectBlacklist.isTracking(host))
return true;
}
} catch (Throwable ex) {
Log.w(ex);
}

Loading…
Cancel
Save