Index: lib/filterClasses.js |
=================================================================== |
--- a/lib/filterClasses.js |
+++ b/lib/filterClasses.js |
@@ -603,28 +603,32 @@ RegExpFilter.fromText = function(text) |
else if (option[0] == "~" && option.substr(1) in RegExpFilter.typeMap) |
{ |
if (contentType == null) |
contentType = RegExpFilter.prototype.contentType; |
contentType &= ~RegExpFilter.typeMap[option.substr(1)]; |
} |
else if (option == "MATCH_CASE") |
matchCase = true; |
+ else if (option == "~MATCH_CASE") |
+ matchCase = false; |
else if (option == "DOMAIN" && typeof value != "undefined") |
domains = value; |
else if (option == "THIRD_PARTY") |
thirdParty = true; |
else if (option == "~THIRD_PARTY") |
thirdParty = false; |
else if (option == "COLLAPSE") |
collapse = true; |
else if (option == "~COLLAPSE") |
collapse = false; |
else if (option == "SITEKEY" && typeof value != "undefined") |
siteKeys = value.split(/\|/); |
+ else |
+ return new InvalidFilter(origText, "Unknown option " + option.toLowerCase()); |
} |
} |
if (!blocking && (contentType == null || (contentType & RegExpFilter.typeMap.DOCUMENT)) && |
(!options || options.indexOf("DOCUMENT") < 0) && !/^\|?[\w\-]+:/.test(text)) |
{ |
// Exception filters shouldn't apply to pages by default unless they start with a protocol name |
if (contentType == null) |
@@ -638,17 +642,17 @@ RegExpFilter.fromText = function(text) |
{ |
if (blocking) |
return new BlockingFilter(origText, text, contentType, matchCase, domains, thirdParty, collapse); |
else |
return new WhitelistFilter(origText, text, contentType, matchCase, domains, thirdParty, siteKeys); |
} |
catch (e) |
{ |
- return new InvalidFilter(text, e); |
+ return new InvalidFilter(origText, e); |
} |
} |
/** |
* Maps type strings like "SCRIPT" or "OBJECT" to bit masks |
*/ |
RegExpFilter.typeMap = { |
OTHER: 1, |
@@ -664,22 +668,21 @@ RegExpFilter.typeMap = { |
OBJECT_SUBREQUEST: 4096, |
DTD: 1, |
MEDIA: 16384, |
FONT: 32768, |
BACKGROUND: 4, // Backwards compat, same as IMAGE |
POPUP: 0x10000000, |
- DONOTTRACK: 0x20000000, |
ELEMHIDE: 0x40000000 |
}; |
-// ELEMHIDE, DONOTTRACK, POPUP option shouldn't be there by default |
-RegExpFilter.prototype.contentType &= ~(RegExpFilter.typeMap.ELEMHIDE | RegExpFilter.typeMap.DONOTTRACK | RegExpFilter.typeMap.POPUP); |
+// ELEMHIDE, POPUP option shouldn't be there by default |
+RegExpFilter.prototype.contentType &= ~(RegExpFilter.typeMap.ELEMHIDE | RegExpFilter.typeMap.POPUP); |
/** |
* Class for blocking filters |
* @param {String} text see Filter() |
* @param {String} regexpSource see RegExpFilter() |
* @param {Number} contentType see RegExpFilter() |
* @param {Boolean} matchCase see RegExpFilter() |
* @param {String} domains see RegExpFilter() |