Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/antiadblockInit.js

Issue 29785581: Issue 6091 - Add checks for overly generic antiadblock filters (Closed) Base URL: https://hg.adblockplus.org/adblockplusui/
Patch Set: Created May 18, 2018, 8:11 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present 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 /* global publicSuffixes */
kzar 2018/05/22 13:24:02 Nit: Seems like we generally write "globals" inste
Jon Sonesen 2018/05/22 21:25:18 Done.
19
18 "use strict"; 20 "use strict";
19 21
20 const {Prefs} = require("prefs"); 22 const {Prefs} = require("prefs");
21 const {ActiveFilter} = require("filterClasses"); 23 const {ActiveFilter} = require("filterClasses");
22 const {FilterStorage} = require("filterStorage"); 24 const {FilterStorage} = require("filterStorage");
23 const {FilterNotifier} = require("filterNotifier"); 25 const {FilterNotifier} = require("filterNotifier");
24 const {Subscription} = require("subscriptionClasses"); 26 const {Subscription} = require("subscriptionClasses");
25 const {Notification} = require("notification"); 27 const {Notification} = require("notification");
26 28
27 exports.initAntiAdblockNotification = function initAntiAdblockNotification() 29 exports.initAntiAdblockNotification = function initAntiAdblockNotification()
(...skipping 16 matching lines...) Expand all
44 function addAntiAdblockNotification(subscription) 46 function addAntiAdblockNotification(subscription)
45 { 47 {
46 let urlFilters = []; 48 let urlFilters = [];
47 for (let filter of subscription.filters) 49 for (let filter of subscription.filters)
48 { 50 {
49 if (filter instanceof ActiveFilter && filter.domains) 51 if (filter instanceof ActiveFilter && filter.domains)
50 { 52 {
51 for (let [domain, included] of filter.domains) 53 for (let [domain, included] of filter.domains)
52 { 54 {
53 let urlFilter = "||" + domain + "^$document"; 55 let urlFilter = "||" + domain + "^$document";
54 if (domain && included && urlFilters.indexOf(urlFilter) == -1) 56 if (domain && included && urlFilters.indexOf(urlFilter) == -1)
kzar 2018/05/22 13:24:02 Seems kinda inefficient how we're doing urlFilters
Jon Sonesen 2018/05/22 18:26:11 I agree here, and was thinking about this. Was not
Thomas Greiner 2018/05/22 18:43:29 I don't know whether it'd be faster and, if so, by
55 urlFilters.push(urlFilter); 57 {
58 if (["COM", "INFO", "ORG", "NET"].indexOf(domain) == -1)
Jon Sonesen 2018/05/18 20:16:18 Is hardly an exhaustive list of TLDs but there are
Thomas Greiner 2018/05/22 12:43:10 All public suffixes (including TLDs) are listed in
kzar 2018/05/22 13:24:02 Yes, I expected we would first check that the doma
Jon Sonesen 2018/05/22 18:26:11 Okay, thanks for that. Was not sure how we handled
59 {
60 if (!(publicSuffixes.hasOwnProperty(domain)))
Thomas Greiner 2018/05/22 12:43:10 Ideally, this logic would be part of `Filter.proto
kzar 2018/05/22 13:24:02 Well you're right that a filter for the domain "co
Thomas Greiner 2018/05/22 17:48:59 That's quite a pity. Nevermind then.
Jon Sonesen 2018/05/22 18:26:11 Acknowledged.
61 urlFilters.push(urlFilter);
62 }
63 }
56 } 64 }
57 } 65 }
58 } 66 }
59 notification.urlFilters = urlFilters; 67 notification.urlFilters = urlFilters;
60 Notification.addNotification(notification); 68 Notification.addNotification(notification);
61 Notification.addQuestionListener(notification.id, notificationListener); 69 Notification.addQuestionListener(notification.id, notificationListener);
62 } 70 }
63 71
64 function removeAntiAdblockNotification() 72 function removeAntiAdblockNotification()
65 { 73 {
(...skipping 16 matching lines...) Expand all
82 if (url in FilterStorage.knownSubscriptions && subscription.disabled) 90 if (url in FilterStorage.knownSubscriptions && subscription.disabled)
83 addAntiAdblockNotification(subscription); 91 addAntiAdblockNotification(subscription);
84 else 92 else
85 removeAntiAdblockNotification(); 93 removeAntiAdblockNotification();
86 } 94 }
87 95
88 FilterNotifier.on("subscription.updated", onSubscriptionChange); 96 FilterNotifier.on("subscription.updated", onSubscriptionChange);
89 FilterNotifier.on("subscription.removed", onSubscriptionChange); 97 FilterNotifier.on("subscription.removed", onSubscriptionChange);
90 FilterNotifier.on("subscription.disabled", onSubscriptionChange); 98 FilterNotifier.on("subscription.disabled", onSubscriptionChange);
91 }; 99 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld