 Issue 5279235799252992:
  Issue 491 - Validate custom filters  (Closed)
    
  
    Issue 5279235799252992:
  Issue 491 - Validate custom filters  (Closed) 
  | Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 
| 3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH | 
| 4 * | 4 * | 
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify | 
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as | 
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. | 
| 8 * | 8 * | 
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, | 
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. | 
| 13 * | 13 * | 
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License | 
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 
| 16 */ | 16 */ | 
| 17 | 17 | 
| 18 with(require("filterClasses")) | 18 with(require("filterClasses")) | 
| 19 { | 19 { | 
| 20 this.Filter = Filter; | 20 this.Filter = Filter; | 
| 21 this.RegExpFilter = RegExpFilter; | 21 this.RegExpFilter = RegExpFilter; | 
| 22 this.BlockingFilter = BlockingFilter; | 22 this.BlockingFilter = BlockingFilter; | 
| 23 this.WhitelistFilter = WhitelistFilter; | 23 this.WhitelistFilter = WhitelistFilter; | 
| 24 this.InvalidFilter = InvalidFilter; | |
| 24 } | 25 } | 
| 25 with(require("subscriptionClasses")) | 26 with(require("subscriptionClasses")) | 
| 26 { | 27 { | 
| 27 this.Subscription = Subscription; | 28 this.Subscription = Subscription; | 
| 28 this.DownloadableSubscription = DownloadableSubscription; | 29 this.DownloadableSubscription = DownloadableSubscription; | 
| 29 this.SpecialSubscription = SpecialSubscription; | 30 this.SpecialSubscription = SpecialSubscription; | 
| 30 } | 31 } | 
| 31 with(require("whitelisting")) | 32 with(require("whitelisting")) | 
| 32 { | 33 { | 
| 33 this.isWhitelisted = isWhitelisted; | 34 this.isWhitelisted = isWhitelisted; | 
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 517 case "get-domain-enabled-state": | 518 case "get-domain-enabled-state": | 
| 518 // Returns whether this domain is in the exclusion list. | 519 // Returns whether this domain is in the exclusion list. | 
| 519 // The browser action popup asks us this. | 520 // The browser action popup asks us this. | 
| 520 if(sender.page) | 521 if(sender.page) | 
| 521 { | 522 { | 
| 522 sendResponse({enabled: !isWhitelisted(sender.page.url)}); | 523 sendResponse({enabled: !isWhitelisted(sender.page.url)}); | 
| 523 return; | 524 return; | 
| 524 } | 525 } | 
| 525 break; | 526 break; | 
| 526 case "add-filters": | 527 case "add-filters": | 
| 527 if (msg.filters && msg.filters.length) | 528 var filters = []; | 
| 529 | |
| 
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
 | |
| 530 for (var i = 0; i < msg.filters.length; i++) | |
| 528 { | 531 { | 
| 529 for (var i = 0; i < msg.filters.length; i++) | 532 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
 | |
| 530 FilterStorage.addFilter(Filter.fromText(msg.filters[i])); | 533 if (filter instanceof InvalidFilter) | 
| 534 { | |
| 535 sendResponse({status: "invalid", error: filter.reason}); | |
| 536 return; | |
| 537 } | |
| 538 filters.push(filter); | |
| 531 } | 539 } | 
| 540 | |
| 541 for (var i = 0; i < filters.length; i++) | |
| 
kzar
2014/11/18 16:32:10
You've re-declared the `i` variable here.
 | |
| 542 FilterStorage.addFilter(filters[i]); | |
| 543 | |
| 544 sendResponse({status: "ok"}); | |
| 532 break; | 545 break; | 
| 533 case "add-subscription": | 546 case "add-subscription": | 
| 534 ext.showOptions(function(page) | 547 ext.showOptions(function(page) | 
| 535 { | 548 { | 
| 536 page.sendMessage(msg); | 549 page.sendMessage(msg); | 
| 537 }); | 550 }); | 
| 538 break; | 551 break; | 
| 539 case "add-sitekey": | 552 case "add-sitekey": | 
| 540 processKey(msg.token, sender.page, sender.frame); | 553 processKey(msg.token, sender.page, sender.frame); | 
| 541 break; | 554 break; | 
| (...skipping 22 matching lines...) Expand all Loading... | |
| 564 page.sendMessage({type: "clickhide-deactivate"}); | 577 page.sendMessage({type: "clickhide-deactivate"}); | 
| 565 refreshIconAndContextMenu(page); | 578 refreshIconAndContextMenu(page); | 
| 566 }); | 579 }); | 
| 567 | 580 | 
| 568 setTimeout(function() | 581 setTimeout(function() | 
| 569 { | 582 { | 
| 570 var notificationToShow = Notification.getNextToShow(); | 583 var notificationToShow = Notification.getNextToShow(); | 
| 571 if (notificationToShow) | 584 if (notificationToShow) | 
| 572 showNotification(notificationToShow); | 585 showNotification(notificationToShow); | 
| 573 }, 3 * 60 * 1000); | 586 }, 3 * 60 * 1000); | 
| OLD | NEW |