Index: lib/filterClasses.js |
=================================================================== |
--- a/lib/filterClasses.js |
+++ b/lib/filterClasses.js |
@@ -382,38 +382,38 @@ |
/** |
* 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() |
{ |
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 |
@@ -480,17 +480,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("."); |
@@ -506,17 +506,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; |
@@ -607,19 +607,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, |
@@ -750,47 +750,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) |
+ .replace(/-/, "_").toUpperCase(); |
+ option = option.toLowerCase(); |
+ if (type in RegExpFilter.typeMap) |
{ |
- 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; |
+ if (type == "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)]; |
- } |
- 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. |