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

Unified Diff: lib/contentPolicy.js

Issue 5840485868371968: Issue 616 - Add $generichide + $genericblock filter options and enforce them. (Closed)
Patch Set: Remove extra parenthesis Created Sept. 28, 2015, 10:15 a.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 | lib/filterClasses.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/contentPolicy.js
diff --git a/lib/contentPolicy.js b/lib/contentPolicy.js
index b0498da6ec3bf66b35e35d8d8114e99ad3477707..eaef9b016156797948a5b3b3f812f4fe8f6d9591 100644
--- a/lib/contentPolicy.js
+++ b/lib/contentPolicy.js
@@ -162,6 +162,8 @@ let Policy = exports.Policy =
let docDomain = getHostname(wndLocation);
let match = null;
let [sitekey, sitekeyWnd] = getSitekey(wnd);
+ let nogeneric = false;
+
if (!match && Prefs.enabled)
{
let testWnd = wnd;
@@ -181,6 +183,23 @@ let Policy = exports.Policy =
return true;
}
+ let genericType = (contentType == Policy.type.ELEMHIDE ?
+ RegExpFilter.typeMap.GENERICHIDE :
+ RegExpFilter.typeMap.GENERICBLOCK);
+ let parentDocDomain = getHostname(parentWndLocation);
+ let nogenericMatch = defaultMatcher.matchesAny(
+ testWndLocation, genericType, parentDocDomain, false, testSitekey
+ );
+ if (nogenericMatch instanceof WhitelistFilter)
+ {
+ nogeneric = true;
+
+ FilterStorage.increaseHitCount(nogenericMatch, wnd);
+ RequestNotifier.addNodeData(testWnd.document, topWnd, contentType,
+ parentDocDomain, false, testWndLocation,
+ nogenericMatch);
+ }
+
if (testWnd.parent == testWnd)
break;
@@ -236,13 +255,17 @@ let Policy = exports.Policy =
RequestNotifier.addNodeData(node, topWnd, contentType, docDomain, false, locationText, exception);
return true;
}
+
+ if (nogeneric && match.isGeneric())
+ return true;
}
let thirdParty = (contentType == Policy.type.ELEMHIDE ? false : isThirdParty(location, docDomain));
if (!match && Prefs.enabled && contentType in Policy.typeMask)
{
- match = defaultMatcher.matchesAny(locationText, Policy.typeMask[contentType], docDomain, thirdParty, sitekey);
+ match = defaultMatcher.matchesAny(locationText, Policy.typeMask[contentType],
+ docDomain, thirdParty, sitekey, nogeneric);
if (match instanceof BlockingFilter && node.ownerDocument && !(contentType in Policy.nonVisual))
{
let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.fastcollapse);
« no previous file with comments | « no previous file | lib/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld