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

Delta Between Two Patch Sets: lib/filterListener.js

Issue 29824589: Issue 6538, 6781 - Allow snippets only from circumvention lists (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created July 6, 2018, 3:18 p.m.
Right Patch Set: Improve unit tests Created July 10, 2018, 7:15 a.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 | test/filterListener.js » ('j') | 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
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 * if necessary. 135 * if necessary.
136 * @param {Filter} filter filter that has been added 136 * @param {Filter} filter filter that has been added
137 */ 137 */
138 function addFilter(filter) 138 function addFilter(filter)
139 { 139 {
140 if (!(filter instanceof ActiveFilter) || filter.disabled) 140 if (!(filter instanceof ActiveFilter) || filter.disabled)
141 return; 141 return;
142 142
143 let hasEnabled = false; 143 let hasEnabled = false;
144 let allowSnippets = false; 144 let allowSnippets = false;
145 for (let i = 0; i < filter.subscriptions.length; i++) 145 for (let i = 0; i < filter.subscriptions.length; i++)
kzar 2018/07/10 14:38:35 Nit: `for (let subscription of filter.subscription
Manish Jethani 2018/07/10 18:33:22 I did this initially and then reverted it. There's
kzar 2018/07/10 18:56:00 Sure it's an unrelated change, but you're changing
Manish Jethani 2018/07/11 15:07:03 There are some performance implications of for..of
kzar 2018/07/11 17:22:07 Fine.
146 { 146 {
147 let subscription = filter.subscriptions[i]; 147 let subscription = filter.subscriptions[i];
148 148
149 if (!subscription.disabled) 149 if (!subscription.disabled)
150 { 150 {
151 hasEnabled = true; 151 hasEnabled = true;
152 152
153 // Allow snippets to be executed only by the circumvention lists or the 153 // Allow snippets to be executed only by the circumvention lists or the
154 // user's own filters. 154 // user's own filters.
155 if (!allowSnippets && 155 if (subscription.type == "circumvention" ||
156 (subscription.type == "circumvention" || 156 subscription instanceof SpecialSubscription)
157 subscription instanceof SpecialSubscription))
158 { 157 {
159 allowSnippets = true; 158 allowSnippets = true;
160 break; 159 break;
161 } 160 }
162 } 161 }
163 } 162 }
164 if (!hasEnabled) 163 if (!hasEnabled)
165 return; 164 return;
166 165
167 if (filter instanceof RegExpFilter) 166 if (filter instanceof RegExpFilter)
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 { 336 {
338 if (!subscription.disabled) 337 if (!subscription.disabled)
339 addFilters(subscription.filters); 338 addFilters(subscription.filters);
340 } 339 }
341 } 340 }
342 341
343 function onSave() 342 function onSave()
344 { 343 {
345 isDirty = 0; 344 isDirty = 0;
346 } 345 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld