Index: lib/abp2blocklist.js |
=================================================================== |
--- a/lib/abp2blocklist.js |
+++ b/lib/abp2blocklist.js |
@@ -271,20 +271,29 @@ |
parseDomains(filter.domains, included, excluded); |
if (exceptionDomains) |
excluded = excluded.concat(exceptionDomains); |
if (withResourceTypes) |
{ |
- trigger["resource-type"] = getResourceTypes(filter); |
+ let resourceTypes = getResourceTypes(filter); |
- if (trigger["resource-type"].length == 0) |
+ // Content blocker rules can't differentiate between sub-document requests |
+ // (iframes) and top-level document requests. To avoid too many false |
+ // positives, we prevent rules with no hostname part from blocking document |
+ // requests. |
kzar
2017/07/07 12:58:03
Maybe add a note that when Safari X is the lowest
Manish Jethani
2017/07/08 11:29:50
Done.
|
+ if (filter instanceof filterClasses.BlockingFilter && !parsed.hostname) |
+ resourceTypes = resourceTypes.filter(type => type != "document"); |
+ |
+ if (resourceTypes.length == 0) |
return; |
+ |
+ trigger["resource-type"] = resourceTypes; |
} |
if (filter.thirdParty != null) |
trigger["load-type"] = [filter.thirdParty ? "third-party" : "first-party"]; |
if (included.length > 0) |
{ |
trigger["if-domain"] = []; |
@@ -310,17 +319,17 @@ |
} |
} |
} |
else if (excluded.length > 0) |
{ |
trigger["unless-domain"] = excluded.map(name => "*" + name); |
} |
else if (filter instanceof filterClasses.BlockingFilter && |
- filter.contentType & typeMap.SUBDOCUMENT) |
+ filter.contentType & typeMap.SUBDOCUMENT && parsed.hostname) |
kzar
2017/07/07 12:58:03
Could you explain why we're checking for a hostnam
Manish Jethani
2017/07/08 11:29:50
There are two parts to this change.
1. For filt
kzar
2017/07/10 13:01:14
Thanks for the explanation, sounds good to me. I l
|
{ |
trigger["unless-top-url"] = [trigger["url-filter"]]; |
if (trigger["url-filter-is-case-sensitive"]) |
trigger["top-url-filter-is-case-sensitive"] = true; |
} |
rules.push({trigger: trigger, action: {type: action}}); |
} |