| Index: lib/matcher.js |
| =================================================================== |
| --- a/lib/matcher.js |
| +++ b/lib/matcher.js |
| @@ -103,38 +103,35 @@ Matcher.prototype = { |
| /** |
| * Chooses a keyword to be associated with the filter |
| * @param {String} text text representation of the filter |
| * @return {String} keyword (might be empty string) |
| */ |
| findKeyword: function(filter) |
| { |
| - // For donottrack filters use "donottrack" as keyword if nothing else matches |
| - let defaultResult = (filter.contentType & RegExpFilter.typeMap.DONOTTRACK ? "donottrack" : ""); |
| - |
| + let result = ""; |
| let text = filter.text; |
| if (Filter.regexpRegExp.test(text)) |
| - return defaultResult; |
| + return result; |
| // Remove options |
| let match = Filter.optionsRegExp.exec(text); |
| if (match) |
| text = match.input.substr(0, match.index); |
| // Remove whitelist marker |
| if (text.substr(0, 2) == "@@") |
| text = text.substr(2); |
| let candidates = text.toLowerCase().match(/[^a-z0-9%*][a-z0-9%]{3,}(?=[^a-z0-9%*])/g); |
| if (!candidates) |
| - return defaultResult; |
| + return result; |
| let hash = this.filterByKeyword; |
| - let result = defaultResult; |
| let resultCount = 0xFFFFFF; |
| let resultLength = 0; |
| for (let i = 0, l = candidates.length; i < l; i++) |
| { |
| let candidate = candidates[i].substr(1); |
| let count = (candidate in hash ? hash[candidate].length : 0); |
| if (count < resultCount || (count == resultCount && candidate.length > resultLength)) |
| { |
| @@ -188,20 +185,17 @@ Matcher.prototype = { |
| * @param {Boolean} thirdParty should be true if the URL is a third-party request |
| * @return {RegExpFilter} matching filter or null |
| */ |
| matchesAny: function(location, contentType, docDomain, thirdParty) |
| { |
| let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g); |
| if (candidates === null) |
| candidates = []; |
| - if (contentType == "DONOTTRACK") |
| - candidates.unshift("donottrack"); |
| - else |
| - candidates.push(""); |
| + candidates.push(""); |
| for (let i = 0, l = candidates.length; i < l; i++) |
| { |
| let substr = candidates[i]; |
| if (substr in this.filterByKeyword) |
| { |
| let result = this._checkEntryMatch(substr, location, contentType, docDomain, thirdParty); |
| if (result) |
| return result; |
| @@ -376,20 +370,17 @@ CombinedMatcher.prototype = |
| * simultaneously. For parameters see Matcher.matchesAny(). |
| * @see Matcher#matchesAny |
| */ |
| matchesAnyInternal: function(location, contentType, docDomain, thirdParty) |
| { |
| let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g); |
| if (candidates === null) |
| candidates = []; |
| - if (contentType == "DONOTTRACK") |
| - candidates.unshift("donottrack"); |
| - else |
| - candidates.push(""); |
| + candidates.push(""); |
| let blacklistHit = null; |
| for (let i = 0, l = candidates.length; i < l; i++) |
| { |
| let substr = candidates[i]; |
| if (substr in this.whitelist.filterByKeyword) |
| { |
| let result = this.whitelist._checkEntryMatch(substr, location, contentType, docDomain, thirdParty); |