Index: lib/filterClasses.js |
diff --git a/lib/filterClasses.js b/lib/filterClasses.js |
index ebfe551604cf296e582fbd6e7cdeca87bbe66237..27dff31eccaa77d4dda7ed512185f8688208873d 100644 |
--- a/lib/filterClasses.js |
+++ b/lib/filterClasses.js |
@@ -22,6 +22,28 @@ |
let {FilterNotifier} = require("filterNotifier"); |
let {extend} = require("coreUtils"); |
+// Helper function used to determine if a filter has any empty domains or not. |
+function emptyDomains(domains, separator) |
+{ |
+ let emptySoFar = true; |
+ for (let i = 0; i < domains.length; i++) |
+ { |
+ switch (domains[i]) |
+ { |
+ case separator: |
+ if (emptySoFar) |
+ return true; |
+ emptySoFar = true; |
+ break; |
+ case "~": |
+ break; |
+ default: |
+ emptySoFar = false; |
+ } |
+ } |
+ return emptySoFar; |
+} |
+ |
/** |
* Abstract base class for filters |
* |
@@ -924,6 +946,9 @@ ElemHideBase.fromText = function(text, domain, isException, tagName, attrRules, |
return new InvalidFilter(text, "filter_elemhide_nocriteria"); |
} |
+ if (domain && emptyDomains(domain, ElemHideBase.prototype.domainSeparator)) |
Wladimir Palant
2016/10/06 08:06:14
Why have this function rather than /(^|,)~?(,|$)/.
kzar
2016/10/06 08:53:55
Done.
|
+ return new InvalidFilter(text, "filter_empty_domain"); |
Wladimir Palant
2016/10/06 08:06:14
filter_invalid_domain? We allow empty domains, but
kzar
2016/10/06 08:53:56
Done.
|
+ |
if (isException) |
return new ElemHideException(text, domain, selector); |