Index: background.js |
=================================================================== |
--- a/background.js |
+++ b/background.js |
@@ -21,6 +21,7 @@ |
this.RegExpFilter = RegExpFilter; |
this.BlockingFilter = BlockingFilter; |
this.WhitelistFilter = WhitelistFilter; |
+ this.InvalidFilter = InvalidFilter; |
} |
with(require("subscriptionClasses")) |
{ |
@@ -524,11 +525,23 @@ |
} |
break; |
case "add-filters": |
- if (msg.filters && msg.filters.length) |
+ var filters = []; |
+ |
kzar
2014/11/18 16:32:10
How come you don't check that msg.filters and msg.
Sebastian Noack
2014/11/18 17:42:55
There was no point in checking it in the first pla
|
+ for (var i = 0; i < msg.filters.length; i++) |
{ |
- for (var i = 0; i < msg.filters.length; i++) |
- FilterStorage.addFilter(Filter.fromText(msg.filters[i])); |
+ var filter = Filter.fromText(msg.filters[i], true); |
kzar
2014/11/18 16:32:10
Instead of having this separate filter variable ho
Sebastian Noack
2014/11/18 17:42:55
We have to access the filter object 3 times (or 2
|
+ if (filter instanceof InvalidFilter) |
+ { |
+ sendResponse({status: "invalid", error: filter.reason}); |
+ return; |
+ } |
+ filters.push(filter); |
} |
+ |
+ for (var i = 0; i < filters.length; i++) |
kzar
2014/11/18 16:32:10
You've re-declared the `i` variable here.
|
+ FilterStorage.addFilter(filters[i]); |
+ |
+ sendResponse({status: "ok"}); |
break; |
case "add-subscription": |
ext.showOptions(function(page) |