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

Delta Between Two Patch Sets: lib/antiadblockInit.js

Issue 29785581: Issue 6091 - Add checks for overly generic antiadblock filters (Closed) Base URL: https://hg.adblockplus.org/adblockplusui/
Left Patch Set: Actually moved all logic to start of iteration Created May 23, 2018, 11:59 p.m.
Right Patch Set: Address PS6 Comments Created May 29, 2018, 8:40 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 /* globals publicSuffixes */ 18 /* globals publicSuffixes */
Thomas Greiner 2018/05/30 10:18:03 Detail: This whitespace appears to have been added
kzar 2018/05/30 10:57:48 The newline? If so it seems consistent with how we
Thomas Greiner 2018/05/30 12:30:09 No, the whitespace character to the left of the co
kzar 2018/05/30 12:59:02 Oh yea, I see what you mean now.
Jon Sonesen 2018/05/30 15:46:54 Acknowledged.
19 19
20 "use strict"; 20 "use strict";
21 21
22 const {Prefs} = require("prefs"); 22 const {Prefs} = require("prefs");
23 const {ActiveFilter} = require("filterClasses"); 23 const {ActiveFilter} = require("filterClasses");
24 const {FilterStorage} = require("filterStorage"); 24 const {FilterStorage} = require("filterStorage");
25 const {FilterNotifier} = require("filterNotifier"); 25 const {FilterNotifier} = require("filterNotifier");
26 const {Subscription} = require("subscriptionClasses"); 26 const {Subscription} = require("subscriptionClasses");
27 const {Notification} = require("notification"); 27 const {Notification} = require("notification");
28 28
(...skipping 16 matching lines...) Expand all
45 45
46 function addAntiAdblockNotification(subscription) 46 function addAntiAdblockNotification(subscription)
47 { 47 {
48 let urlFilters = []; 48 let urlFilters = [];
49 for (let filter of subscription.filters) 49 for (let filter of subscription.filters)
50 { 50 {
51 if (filter instanceof ActiveFilter && filter.domains) 51 if (filter instanceof ActiveFilter && filter.domains)
52 { 52 {
53 for (let [domain, included] of filter.domains) 53 for (let [domain, included] of filter.domains)
54 { 54 {
55 let domainIsTLD = !domain.includes(".") || domain.endsWith(".");
kzar 2018/05/25 13:51:56 This logic doesn't look right to me, what about th
kzar 2018/05/25 13:51:57 This variable seems kind of pointless, when we onl
Jon Sonesen 2018/05/25 21:04:39 Hm, but there is the case where `com.` and `com` s
56 if (domainIsTLD || publicSuffixes.hasOwnProperty(domain))
kzar 2018/05/25 13:51:57 If the domain ends in "." it won't be found in pub
Jon Sonesen 2018/05/25 21:04:39 Acknowledged.
57 continue;
58 let urlFilter = "||" + domain + "^$document"; 55 let urlFilter = "||" + domain + "^$document";
59 if (domain && included && urlFilters.indexOf(urlFilter) == -1) 56 if (domain && included && urlFilters.indexOf(urlFilter) == -1)
kzar 2018/05/25 13:51:57 It seems a shame we're doing these cheaper checks
Jon Sonesen 2018/05/25 21:04:39 Acknowledged.
60 { 57 {
61 urlFilters.push(urlFilter); 58 if (/\.[^$]/.test(domain) && !publicSuffixes.hasOwnProperty(domain))
kzar 2018/05/30 10:57:48 Please combine the two if statements. Also please
Thomas Greiner 2018/05/30 12:30:09 Good call. This regex will indeed fail for multi-p
kzar 2018/05/30 12:59:02 Well my concern was that "co.uk" is in the publicS
Jon Sonesen 2018/05/30 15:46:54 Unit tests it is then!
59 {
60 urlFilters.push(urlFilter);
61 }
62 } 62 }
63 } 63 }
64 } 64 }
65 } 65 }
66 notification.urlFilters = urlFilters; 66 notification.urlFilters = urlFilters;
67 Notification.addNotification(notification); 67 Notification.addNotification(notification);
68 Notification.addQuestionListener(notification.id, notificationListener); 68 Notification.addQuestionListener(notification.id, notificationListener);
69 } 69 }
70 70
71 function removeAntiAdblockNotification() 71 function removeAntiAdblockNotification()
(...skipping 17 matching lines...) Expand all
89 if (url in FilterStorage.knownSubscriptions && subscription.disabled) 89 if (url in FilterStorage.knownSubscriptions && subscription.disabled)
90 addAntiAdblockNotification(subscription); 90 addAntiAdblockNotification(subscription);
91 else 91 else
92 removeAntiAdblockNotification(); 92 removeAntiAdblockNotification();
93 } 93 }
94 94
95 FilterNotifier.on("subscription.updated", onSubscriptionChange); 95 FilterNotifier.on("subscription.updated", onSubscriptionChange);
96 FilterNotifier.on("subscription.removed", onSubscriptionChange); 96 FilterNotifier.on("subscription.removed", onSubscriptionChange);
97 FilterNotifier.on("subscription.disabled", onSubscriptionChange); 97 FilterNotifier.on("subscription.disabled", onSubscriptionChange);
98 }; 98 };
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld