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: Rebased. Created Aug. 22, 2016, 4:31 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 e9bbd1c00ef7826b4b6b0ad48ed12d7889c8a527..50fd122cd08b5804870e1c34dab6e95f72712407 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);
+ }
+
if (trigger["resource-type"].length == 0)
return;
}
« 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