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

Side by Side Diff: lib/abp2blocklist.js

Issue 29443587: Noissue - Do not add subdomain wildcard if subdomain excluded (Closed) Base URL: https://hg.adblockplus.org/abp2blocklist
Patch Set: Created May 20, 2017, 11:50 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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 trigger["resource-type"] = getResourceTypes(filter); 261 trigger["resource-type"] = getResourceTypes(filter);
262 262
263 if (trigger["resource-type"].length == 0) 263 if (trigger["resource-type"].length == 0)
264 return; 264 return;
265 } 265 }
266 266
267 if (filter.thirdParty != null) 267 if (filter.thirdParty != null)
268 trigger["load-type"] = [filter.thirdParty ? "third-party" : "first-party"]; 268 trigger["load-type"] = [filter.thirdParty ? "third-party" : "first-party"];
269 269
270 if (included.length > 0) 270 if (included.length > 0)
271 trigger["if-domain"] = included.map(name => "*" + name); 271 {
272 trigger["if-domain"] = included.map(name =>
273 {
274 if (filter instanceof filterClasses.WhitelistFilter)
275 return "*" + name;
276
277 // If this is not a whitelisting filter, add the subdomain wildcard only
278 // if no subdomains have been excluded.
279 let regExp = new RegExp("\." + escapeRegExp(name) + "$");
280 if (!excluded.some(name => regExp.test(name)))
281 return "*" + name;
282
283 return name;
284 });
285 }
272 else if (excluded.length > 0) 286 else if (excluded.length > 0)
287 {
273 trigger["unless-domain"] = excluded.map(name => "*" + name); 288 trigger["unless-domain"] = excluded.map(name => "*" + name);
289 }
274 290
275 rules.push({trigger: trigger, action: {type: action}}); 291 rules.push({trigger: trigger, action: {type: action}});
276 } 292 }
277 293
278 function hasNonASCI(obj) 294 function hasNonASCI(obj)
279 { 295 {
280 if (typeof obj == "string") 296 if (typeof obj == "string")
281 { 297 {
282 if (/[^\x00-\x7F]/.test(obj)) 298 if (/[^\x00-\x7F]/.test(obj))
283 return true; 299 return true;
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 467
452 for (let filter of this.elemhideExceptions) 468 for (let filter of this.elemhideExceptions)
453 convertFilterAddRules(rules, filter, "ignore-previous-rules", false); 469 convertFilterAddRules(rules, filter, "ignore-previous-rules", false);
454 for (let filter of this.requestFilters) 470 for (let filter of this.requestFilters)
455 convertFilterAddRules(rules, filter, "block", true); 471 convertFilterAddRules(rules, filter, "block", true);
456 for (let filter of this.requestExceptions) 472 for (let filter of this.requestExceptions)
457 convertFilterAddRules(rules, filter, "ignore-previous-rules", true); 473 convertFilterAddRules(rules, filter, "ignore-previous-rules", true);
458 474
459 return rules.filter(rule => !hasNonASCI(rule)); 475 return rules.filter(rule => !hasNonASCI(rule));
460 }; 476 };
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