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

Delta Between Two Patch Sets: lib/abp2blocklist.js

Issue 29349989: Issue 4327 - Prevent generic document blocking (Closed)
Left Patch Set: Created Aug. 19, 2016, 5:55 p.m.
Right Patch Set: Rebased. Created Aug. 22, 2016, 4:31 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 | test/abp2blocklist.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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // requests (iframes) and top-level document requests (redirects). So to 280 // requests (iframes) and top-level document requests (redirects). So to
281 // avoid too many false-positives we stop generic rules (no hostname part) 281 // avoid too many false-positives we stop generic rules (no hostname part)
282 // from blocking document requests. 282 // from blocking document requests.
283 if (action == "block" && !parsed.hostname) 283 if (action == "block" && !parsed.hostname)
284 { 284 {
285 let documentIndex = trigger["resource-type"].indexOf("document"); 285 let documentIndex = trigger["resource-type"].indexOf("document");
286 if (documentIndex > -1) 286 if (documentIndex > -1)
287 trigger["resource-type"].splice(documentIndex, 1); 287 trigger["resource-type"].splice(documentIndex, 1);
288 } 288 }
289 289
290 // Rules with no resource types to match shouldn't match anything and
291 // therefore shouldn't be created.
292 if (trigger["resource-type"].length == 0) 290 if (trigger["resource-type"].length == 0)
293 return; 291 return;
294 } 292 }
295 293
296 if (filter.thirdParty != null) 294 if (filter.thirdParty != null)
297 trigger["load-type"] = [filter.thirdParty ? "third-party" : "first-party"]; 295 trigger["load-type"] = [filter.thirdParty ? "third-party" : "first-party"];
298 296
299 if (included.length > 0) 297 if (included.length > 0)
300 trigger["if-domain"] = addDomainPrefix(included); 298 trigger["if-domain"] = addDomainPrefix(included);
301 else if (excluded.length > 0) 299 else if (excluded.length > 0)
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 478
481 for (let filter of this.elemhideExceptions) 479 for (let filter of this.elemhideExceptions)
482 convertFilterAddRules(rules, filter, "ignore-previous-rules", false); 480 convertFilterAddRules(rules, filter, "ignore-previous-rules", false);
483 for (let filter of this.requestFilters) 481 for (let filter of this.requestFilters)
484 convertFilterAddRules(rules, filter, "block", true); 482 convertFilterAddRules(rules, filter, "block", true);
485 for (let filter of this.requestExceptions) 483 for (let filter of this.requestExceptions)
486 convertFilterAddRules(rules, filter, "ignore-previous-rules", true); 484 convertFilterAddRules(rules, filter, "ignore-previous-rules", true);
487 485
488 return rules.filter(rule => !hasNonASCI(rule)); 486 return rules.filter(rule => !hasNonASCI(rule));
489 }; 487 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld