| Index: lib/matcher.js |
| diff --git a/lib/matcher.js b/lib/matcher.js |
| index 3aedf9ba310f6f21dfcd3910a948c15e6a5d1802..dbe77cba3e57d96189a86f39efc768d5734e5952 100644 |
| --- a/lib/matcher.js |
| +++ b/lib/matcher.js |
| @@ -165,12 +165,17 @@ Matcher.prototype = { |
| /** |
| * Checks whether the entries for a particular keyword match a URL |
| */ |
| - _checkEntryMatch: function(keyword, location, typeMask, docDomain, thirdParty, sitekey) |
| + _checkEntryMatch: function(keyword, location, typeMask, docDomain, thirdParty, sitekey, specificOnly) |
| { |
| let list = this.filterByKeyword[keyword]; |
| for (let i = 0; i < list.length; i++) |
| { |
| let filter = list[i]; |
| + |
| + if (specificOnly && filter.isGeneric() && |
| + !(filter instanceof WhitelistFilter)) |
| + continue; |
| + |
| if (filter.matches(location, typeMask, docDomain, thirdParty, sitekey)) |
| return filter; |
| } |
| @@ -184,9 +189,10 @@ Matcher.prototype = { |
| * @param {String} docDomain domain name of the document that loads the URL |
| * @param {Boolean} thirdParty should be true if the URL is a third-party request |
| * @param {String} sitekey public key provided by the document |
| + * @param {Boolean} specificOnly should be true if generic matches should be ignored |
| * @return {RegExpFilter} matching filter or null |
| */ |
| - matchesAny: function(location, typeMask, docDomain, thirdParty, sitekey) |
| + matchesAny: function(location, typeMask, docDomain, thirdParty, sitekey, specificOnly) |
| { |
| let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g); |
| if (candidates === null) |
| @@ -197,7 +203,7 @@ Matcher.prototype = { |
| let substr = candidates[i]; |
| if (substr in this.filterByKeyword) |
| { |
| - let result = this._checkEntryMatch(substr, location, typeMask, docDomain, thirdParty, sitekey); |
| + let result = this._checkEntryMatch(substr, location, typeMask, docDomain, thirdParty, sitekey, specificOnly); |
| if (result) |
| return result; |
| } |
| @@ -347,7 +353,7 @@ CombinedMatcher.prototype = |
| * simultaneously. For parameters see Matcher.matchesAny(). |
| * @see Matcher#matchesAny |
| */ |
| - matchesAnyInternal: function(location, typeMask, docDomain, thirdParty, sitekey) |
| + matchesAnyInternal: function(location, typeMask, docDomain, thirdParty, sitekey, specificOnly) |
| { |
| let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g); |
| if (candidates === null) |
| @@ -365,7 +371,7 @@ CombinedMatcher.prototype = |
| return result; |
| } |
| if (substr in this.blacklist.filterByKeyword && blacklistHit === null) |
| - blacklistHit = this.blacklist._checkEntryMatch(substr, location, typeMask, docDomain, thirdParty, sitekey); |
| + blacklistHit = this.blacklist._checkEntryMatch(substr, location, typeMask, docDomain, thirdParty, sitekey, specificOnly); |
| } |
| return blacklistHit; |
| }, |
| @@ -373,13 +379,13 @@ CombinedMatcher.prototype = |
| /** |
| * @see Matcher#matchesAny |
| */ |
| - matchesAny: function(location, typeMask, docDomain, thirdParty, sitekey) |
| + matchesAny: function(location, typeMask, docDomain, thirdParty, sitekey, specificOnly) |
| { |
| - let key = location + " " + typeMask + " " + docDomain + " " + thirdParty + " " + sitekey; |
| + let key = location + " " + typeMask + " " + docDomain + " " + thirdParty + " " + sitekey + " " + specificOnly; |
| if (key in this.resultCache) |
| return this.resultCache[key]; |
| - let result = this.matchesAnyInternal(location, typeMask, docDomain, thirdParty, sitekey); |
| + let result = this.matchesAnyInternal(location, typeMask, docDomain, thirdParty, sitekey, specificOnly); |
| if (this.cacheEntries >= CombinedMatcher.maxCacheEntries) |
| { |