Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/abp2blocklist.js

Issue 29349989: Issue 4327 - Prevent generic document blocking (Closed)
Patch Set: Created Aug. 19, 2016, 5:55 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/abp2blocklist.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/abp2blocklist.js
diff --git a/lib/abp2blocklist.js b/lib/abp2blocklist.js
index c86cb9d4b55725a8a44399bb853bcab7381d4521..4ac4453a010ad7ec0f1585b89d3dee6d1b9dab2d 100644
--- a/lib/abp2blocklist.js
+++ b/lib/abp2blocklist.js
@@ -276,6 +276,17 @@ function convertFilterAddRules(rules, filter, action, withResourceTypes)
{
trigger["resource-type"] = getResourceTypes(filter);
+ // Content Blocking rules can't differentiate between sub-document
+ // requests (iframes) and top-level document requests (redirects). So to
+ // avoid too many false-positives we stop generic rules (no hostname part)
+ // from blocking document requests.
+ if (action == "block" && !parsed.hostname)
+ {
+ let documentIndex = trigger["resource-type"].indexOf("document");
+ if (documentIndex > -1)
+ trigger["resource-type"].splice(documentIndex, 1);
+ }
+
// Rules with no resource types to match shouldn't match anything and
// therefore shouldn't be created.
if (trigger["resource-type"].length == 0)
« no previous file with comments | « no previous file | test/abp2blocklist.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld