Index: lib/filterClasses.js |
=================================================================== |
--- a/lib/filterClasses.js |
+++ b/lib/filterClasses.js |
@@ -382,21 +382,21 @@ |
/** |
* Separator character used in domainSource property, must be |
* overridden by subclasses |
* @type {string} |
*/ |
domainSeparator: null, |
/** |
- * Determines whether domainSource is already upper-case, |
+ * Determines whether domainSource is already lower-case, |
* can be overridden by subclasses. |
* @type {boolean} |
*/ |
- domainSourceIsUpperCase: false, |
+ domainSourceIsLowerCase: false, |
/** |
* Map containing domains that this filter should match on/not match |
* on or null if the filter should match on all domains |
* @type {?Map.<string,boolean>} |
*/ |
get domains() |
{ |
@@ -406,20 +406,20 @@ |
if (prop) |
return prop.value; |
let domains = null; |
if (this.domainSource) |
{ |
let source = this.domainSource; |
- if (!this.domainSourceIsUpperCase) |
+ if (!this.domainSourceIsLowerCase) |
{ |
- // RegExpFilter already have uppercase domains |
- source = source.toUpperCase(); |
+ // RegExpFilter already have lowercase domains |
+ source = source.toLowerCase(); |
} |
let list = source.split(this.domainSeparator); |
if (list.length == 1 && list[0][0] != "~") |
{ |
// Fast track for the common one-domain scenario |
domains = new Map([["", false], [list[0], true]]); |
} |
else |
@@ -486,17 +486,17 @@ |
if (!this.domains) |
return true; |
// If the document has no host name, match only if the filter |
// isn't restricted to specific domains |
if (!docDomain) |
return this.domains.get(""); |
- docDomain = docDomain.replace(/\.+$/, "").toUpperCase(); |
+ docDomain = docDomain.replace(/\.+$/, "").toLowerCase(); |
while (true) |
{ |
let isDomainIncluded = this.domains.get(docDomain); |
if (typeof isDomainIncluded != "undefined") |
return isDomainIncluded; |
let nextDot = docDomain.indexOf("."); |
@@ -512,17 +512,17 @@ |
* @param {string} docDomain |
* @return {boolean} |
*/ |
isActiveOnlyOnDomain(docDomain) |
{ |
if (!docDomain || !this.domains || this.domains.get("")) |
return false; |
- docDomain = docDomain.replace(/\.+$/, "").toUpperCase(); |
+ docDomain = docDomain.replace(/\.+$/, "").toLowerCase(); |
for (let [domain, isIncluded] of this.domains) |
{ |
if (isIncluded && domain != docDomain) |
{ |
if (domain.length <= docDomain.length) |
return false; |
@@ -613,19 +613,19 @@ |
// No need to convert this filter to regular expression yet, do it on demand |
this.regexpSource = regexpSource; |
} |
} |
exports.RegExpFilter = RegExpFilter; |
RegExpFilter.prototype = extend(ActiveFilter, { |
/** |
- * @see ActiveFilter.domainSourceIsUpperCase |
+ * @see ActiveFilter.domainSourceIsLowerCase |
*/ |
- domainSourceIsUpperCase: true, |
+ domainSourceIsLowerCase: true, |
/** |
* Number of filters contained, will always be 1 (required to |
* optimize Matcher). |
* @type {number} |
*/ |
length: 1, |
@@ -768,49 +768,54 @@ |
{ |
let value = null; |
let separatorIndex = option.indexOf("="); |
if (separatorIndex >= 0) |
{ |
value = option.substr(separatorIndex + 1); |
option = option.substr(0, separatorIndex); |
} |
- option = option.replace(/-/, "_").toUpperCase(); |
- if (option in RegExpFilter.typeMap) |
+ let type = (option[0] == "~" ? option.substr(1) : option) |
Manish Jethani
2018/06/06 14:59:13
This part may seem unrelated but the goal is to av
|
+ .replace(/-/, "_").toUpperCase(); |
+ option = option.toLowerCase(); |
+ if (type in RegExpFilter.typeMap) |
{ |
- if (contentType == null) |
- contentType = 0; |
- contentType |= RegExpFilter.typeMap[option]; |
+ if (option[0] == "~") |
+ { |
+ if (contentType == null) |
+ ({contentType} = RegExpFilter.prototype); |
+ contentType &= ~RegExpFilter.typeMap[type]; |
+ } |
+ else |
+ { |
+ if (contentType == null) |
+ contentType = 0; |
+ contentType |= RegExpFilter.typeMap[type]; |
- if (option == "CSP" && value) |
- csp = value; |
- } |
- else if (option[0] == "~" && option.substr(1) in RegExpFilter.typeMap) |
- { |
- if (contentType == null) |
- ({contentType} = RegExpFilter.prototype); |
- contentType &= ~RegExpFilter.typeMap[option.substr(1)]; |
+ if (type == "CSP" && value) |
+ csp = value; |
+ } |
} |
- else if (option == "MATCH_CASE") |
+ else if (option == "match-case") |
matchCase = true; |
- else if (option == "~MATCH_CASE") |
+ else if (option == "~match-case") |
matchCase = false; |
- else if (option == "DOMAIN" && value) |
- domains = value.toUpperCase(); |
- else if (option == "THIRD_PARTY") |
+ else if (option == "domain" && value) |
+ domains = value.toLowerCase(); |
+ else if (option == "third-party") |
thirdParty = true; |
- else if (option == "~THIRD_PARTY") |
+ else if (option == "~third-party") |
thirdParty = false; |
- else if (option == "COLLAPSE") |
+ else if (option == "collapse") |
collapse = true; |
- else if (option == "~COLLAPSE") |
+ else if (option == "~collapse") |
collapse = false; |
- else if (option == "SITEKEY" && value) |
+ else if (option == "sitekey" && value) |
sitekeys = value.toUpperCase(); |
- else if (option == "REWRITE" && value) |
+ else if (option == "rewrite" && value) |
rewrite = value; |
else |
return new InvalidFilter(origText, "filter_unknown_option"); |
} |
} |
// For security reasons, never match $rewrite filters |
// against requests that might load any code to be executed. |