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

Unified Diff: lib/matcher.js

Issue 29896562: Issue 7003 - Look up whitelist filter only if URL is blocked (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Rebase Created Oct. 21, 2018, 2:29 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/matcher.js
===================================================================
--- a/lib/matcher.js
+++ b/lib/matcher.js
@@ -315,34 +315,44 @@
matchesAnyInternal(location, typeMask, docDomain, thirdParty, sitekey,
specificOnly)
{
let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g);
if (candidates === null)
candidates = [];
candidates.push("");
+ let whitelistHit = null;
let blacklistHit = null;
+
for (let i = 0, l = candidates.length; i < l; i++)
{
let substr = candidates[i];
- let result = this.whitelist._checkEntryMatch(
- substr, location, typeMask, docDomain, thirdParty, sitekey
+ blacklistHit = this.blacklist._checkEntryMatch(
+ substr, location, typeMask, docDomain, thirdParty, sitekey,
+ specificOnly
);
- if (result)
- return result;
- if (blacklistHit === null)
+ if (blacklistHit)
+ break;
+ }
+
+ if (blacklistHit)
+ {
+ for (let i = 0, l = candidates.length; i < l; i++)
{
- blacklistHit = this.blacklist._checkEntryMatch(
- substr, location, typeMask, docDomain, thirdParty, sitekey,
- specificOnly
+ let substr = candidates[i];
+ whitelistHit = this.whitelist._checkEntryMatch(
+ substr, location, typeMask, docDomain, thirdParty, sitekey
);
+ if (whitelistHit)
+ break;
}
}
- return blacklistHit;
+
+ return whitelistHit || blacklistHit;
}
/**
* @see Matcher#matchesAny
* @inheritdoc
*/
matchesAny(location, typeMask, docDomain, thirdParty, sitekey, specificOnly)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld