Index: lib/matcher.js |
=================================================================== |
--- a/lib/matcher.js |
+++ b/lib/matcher.js |
@@ -463,28 +463,25 @@ |
} |
} |
} |
return null; |
} |
_checkEntryMatchSimple(keyword, location, typeMask, docDomain, thirdParty, |
- sitekey, specificOnly, collection) |
+ sitekey, collection) |
{ |
let filters = this._simpleFiltersByKeyword.get(keyword); |
if (filters) |
{ |
let lowerCaseLocation = location.toLowerCase(); |
for (let filter of filters) |
{ |
- if (specificOnly && !(filter instanceof WhitelistFilter)) |
Manish Jethani
2019/02/26 11:54:24
There's no need for this check. We already decided
|
- continue; |
- |
if (filter.matchesLocation(location, lowerCaseLocation)) |
{ |
if (!collection) |
return filter; |
collection.push(filter); |
} |
} |
@@ -499,18 +496,17 @@ |
let filtersForType = this._filterMapsByType.get(typeMask); |
if (filtersForType) |
{ |
let filters = filtersForType.get(keyword); |
if (filters) |
{ |
for (let filter of filters) |
{ |
- if (specificOnly && filter.isGeneric() && |
Manish Jethani
2019/02/26 11:54:24
We decided not to do these checks in Matcher (chan
|
- !(filter instanceof WhitelistFilter)) |
+ if (specificOnly && filter.isGeneric()) |
continue; |
if (filter.matches(location, typeMask, docDomain, thirdParty, |
sitekey)) |
{ |
if (!collection) |
return filter; |
@@ -533,19 +529,26 @@ |
{ |
return this._matchFiltersByDomain(filtersByDomain, location, typeMask, |
docDomain, thirdParty, sitekey, |
specificOnly, collection); |
} |
// Because of the memory optimization in the add function, most of the |
// time this will be a filter rather than a map. |
- return this._matchFilterWithoutDomain(filtersByDomain, location, |
- typeMask, thirdParty, sitekey, |
- collection); |
+ |
+ // Also see #7312: If it's a single filter, it's always the equivalent of |
+ // Map { "" => Map { filter => true } } (i.e. applies to any domain). If |
+ // the specific-only flag is set, we skip it. |
+ if (!specificOnly) |
+ { |
+ return this._matchFilterWithoutDomain(filtersByDomain, location, |
+ typeMask, thirdParty, sitekey, |
+ collection); |
+ } |
} |
return null; |
} |
/** |
* Checks whether the entries for a particular keyword match a URL |
* @param {string} keyword |
@@ -566,17 +569,17 @@ |
specificOnly, collection) |
{ |
// We need to skip the simple (location-only) filters if the type mask does |
// not contain any default content types. |
if (!specificOnly && (typeMask & DEFAULT_TYPES) != 0) |
{ |
let filter = this._checkEntryMatchSimple(keyword, location, typeMask, |
docDomain, thirdParty, sitekey, |
- specificOnly, collection); |
+ collection); |
if (filter) |
return filter; |
} |
// If the type mask contains a non-default type (first condition) and it is |
// the only type in the mask (second condition), we can use the |
// type-specific map, which typically contains a lot fewer filters. This |
// enables faster lookups for whitelisting types like $document, $elemhide, |