Index: lib/contentPolicy.js |
diff --git a/lib/contentPolicy.js b/lib/contentPolicy.js |
index b1a49c1353d9c6af75e43ba9fc1ceb220db5ac1a..b0498da6ec3bf66b35e35d8d8114e99ad3477707 100644 |
--- a/lib/contentPolicy.js |
+++ b/lib/contentPolicy.js |
@@ -25,7 +25,7 @@ Cu.import("resource://gre/modules/Services.jsm"); |
let {Utils} = require("utils"); |
let {Prefs} = require("prefs"); |
let {FilterStorage} = require("filterStorage"); |
-let {BlockingFilter, WhitelistFilter} = require("filterClasses"); |
+let {BlockingFilter, WhitelistFilter, RegExpFilter} = require("filterClasses"); |
let {defaultMatcher} = require("matcher"); |
let {objectMouseEventHander} = require("objectTabs"); |
let {RequestNotifier} = require("requestNotifier"); |
@@ -67,6 +67,12 @@ let Policy = exports.Policy = |
typeDescr: {}, |
/** |
+ * Map of numerical content types with their corresponding masks |
+ * @type Object |
+ */ |
+ typeMask: {}, |
+ |
+ /** |
* Map of localized content type names by their identifiers. |
* @type Object |
*/ |
@@ -99,16 +105,19 @@ let Policy = exports.Policy = |
this.type[typeName] = id; |
this.typeDescr[id] = typeName; |
this.localizedDescr[id] = Utils.getString("type_label_" + typeName.toLowerCase()); |
+ this.typeMask[id] = RegExpFilter.typeMap[typeName]; |
} |
} |
this.type.ELEMHIDE = 0xFFFD; |
this.typeDescr[0xFFFD] = "ELEMHIDE"; |
this.localizedDescr[0xFFFD] = Utils.getString("type_label_elemhide"); |
+ this.typeMask[0xFFFD] = RegExpFilter.typeMap.ELEMHIDE; |
this.type.POPUP = 0xFFFE; |
this.typeDescr[0xFFFE] = "POPUP"; |
this.localizedDescr[0xFFFE] = Utils.getString("type_label_popup"); |
+ this.typeMask[0xFFFE] = RegExpFilter.typeMap.POPUP; |
for (let type of nonVisualTypes) |
this.nonVisual[this.type[type]] = true; |
@@ -199,7 +208,7 @@ let Policy = exports.Policy = |
let testWndLocation = parentWndLocation; |
parentWndLocation = (testWnd == testWnd.parent ? testWndLocation : getWindowLocation(testWnd.parent)); |
let parentDocDomain = getHostname(parentWndLocation); |
- match = defaultMatcher.matchesAny(testWndLocation, "ELEMHIDE", parentDocDomain, false, sitekey); |
+ match = defaultMatcher.matchesAny(testWndLocation, RegExpFilter.typeMap.ELEMHIDE, parentDocDomain, false, sitekey); |
if (match instanceof WhitelistFilter) |
{ |
FilterStorage.increaseHitCount(match, wnd); |
@@ -231,9 +240,9 @@ let Policy = exports.Policy = |
let thirdParty = (contentType == Policy.type.ELEMHIDE ? false : isThirdParty(location, docDomain)); |
- if (!match && Prefs.enabled) |
+ if (!match && Prefs.enabled && contentType in Policy.typeMask) |
{ |
- match = defaultMatcher.matchesAny(locationText, Policy.typeDescr[contentType] || "", docDomain, thirdParty, sitekey); |
+ match = defaultMatcher.matchesAny(locationText, Policy.typeMask[contentType], docDomain, thirdParty, sitekey); |
if (match instanceof BlockingFilter && node.ownerDocument && !(contentType in Policy.nonVisual)) |
{ |
let prefCollapse = (match.collapse != null ? match.collapse : !Prefs.fastcollapse); |
@@ -292,7 +301,7 @@ let Policy = exports.Policy = |
if (index >= 0) |
url = url.substring(0, index); |
- let result = defaultMatcher.matchesAny(url, "DOCUMENT", getHostname(parentUrl), false, sitekey); |
+ let result = defaultMatcher.matchesAny(url, RegExpFilter.typeMap.DOCUMENT, getHostname(parentUrl), false, sitekey); |
return (result instanceof WhitelistFilter ? result : null); |
}, |