| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 if (exceptionDomains) | 274 if (exceptionDomains) |
| 275 excluded = excluded.concat(exceptionDomains); | 275 excluded = excluded.concat(exceptionDomains); |
| 276 | 276 |
| 277 if (withResourceTypes) | 277 if (withResourceTypes) |
| 278 { | 278 { |
| 279 let resourceTypes = getResourceTypes(filter); | 279 let resourceTypes = getResourceTypes(filter); |
| 280 | 280 |
| 281 // Content blocker rules can't differentiate between sub-document requests | 281 // Content blocker rules can't differentiate between sub-document requests |
| 282 // (iframes) and top-level document requests. To avoid too many false | 282 // (iframes) and top-level document requests. To avoid too many false |
| 283 // positives, we prevent rules with no hostname part from blocking document | 283 // positives, we prevent rules with no hostname part from blocking document |
| 284 // requests. | 284 // requests. |
|
kzar
2017/07/07 12:58:03
Maybe add a note that when Safari X is the lowest
Manish Jethani
2017/07/08 11:29:50
Done.
| |
| 285 // | |
| 286 // Once Safari 11 becomes our minimum supported version, we could change | |
| 287 // our approach here to use the new "unless-top-url" property instead. | |
| 285 if (filter instanceof filterClasses.BlockingFilter && !parsed.hostname) | 288 if (filter instanceof filterClasses.BlockingFilter && !parsed.hostname) |
| 286 resourceTypes = resourceTypes.filter(type => type != "document"); | 289 resourceTypes = resourceTypes.filter(type => type != "document"); |
| 287 | 290 |
| 288 if (resourceTypes.length == 0) | 291 if (resourceTypes.length == 0) |
| 289 return; | 292 return; |
| 290 | 293 |
| 291 trigger["resource-type"] = resourceTypes; | 294 trigger["resource-type"] = resourceTypes; |
| 292 } | 295 } |
| 293 | 296 |
| 294 if (filter.thirdParty != null) | 297 if (filter.thirdParty != null) |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 317 { | 320 { |
| 318 trigger["if-domain"].push("*" + name); | 321 trigger["if-domain"].push("*" + name); |
| 319 } | 322 } |
| 320 } | 323 } |
| 321 } | 324 } |
| 322 else if (excluded.length > 0) | 325 else if (excluded.length > 0) |
| 323 { | 326 { |
| 324 trigger["unless-domain"] = excluded.map(name => "*" + name); | 327 trigger["unless-domain"] = excluded.map(name => "*" + name); |
| 325 } | 328 } |
| 326 else if (filter instanceof filterClasses.BlockingFilter && | 329 else if (filter instanceof filterClasses.BlockingFilter && |
| 327 filter.contentType & typeMap.SUBDOCUMENT && parsed.hostname) | 330 filter.contentType & typeMap.SUBDOCUMENT && parsed.hostname) |
|
kzar
2017/07/07 12:58:03
Could you explain why we're checking for a hostnam
Manish Jethani
2017/07/08 11:29:50
There are two parts to this change.
1. For filt
kzar
2017/07/10 13:01:14
Thanks for the explanation, sounds good to me. I l
| |
| 328 { | 331 { |
| 332 // Rules with a hostname part are still allowed to block document requests, | |
| 333 // but we add an exception for top-level documents. | |
| 334 // | |
| 335 // Note that we can only do this if there's no "unless-domain" property for | |
| 336 // now. This also only works in Safari 11 onwards, while older versions | |
| 337 // simply ignore this property. Once Safari 11 becomes our minimum | |
| 338 // supported version, we can merge "unless-domain" into "unless-top-url". | |
| 329 trigger["unless-top-url"] = [trigger["url-filter"]]; | 339 trigger["unless-top-url"] = [trigger["url-filter"]]; |
| 330 if (trigger["url-filter-is-case-sensitive"]) | 340 if (trigger["url-filter-is-case-sensitive"]) |
| 331 trigger["top-url-filter-is-case-sensitive"] = true; | 341 trigger["top-url-filter-is-case-sensitive"] = true; |
| 332 } | 342 } |
| 333 | 343 |
| 334 rules.push({trigger: trigger, action: {type: action}}); | 344 rules.push({trigger: trigger, action: {type: action}}); |
| 335 } | 345 } |
| 336 | 346 |
| 337 function hasNonASCI(obj) | 347 function hasNonASCI(obj) |
| 338 { | 348 { |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 { | 558 { |
| 549 convertFilterAddRules(rules, filter, "block", true, | 559 convertFilterAddRules(rules, filter, "block", true, |
| 550 requestFilterExceptionDomains); | 560 requestFilterExceptionDomains); |
| 551 } | 561 } |
| 552 | 562 |
| 553 for (let filter of this.requestExceptions) | 563 for (let filter of this.requestExceptions) |
| 554 convertFilterAddRules(rules, filter, "ignore-previous-rules", true); | 564 convertFilterAddRules(rules, filter, "ignore-previous-rules", true); |
| 555 | 565 |
| 556 return rules.filter(rule => !hasNonASCI(rule)); | 566 return rules.filter(rule => !hasNonASCI(rule)); |
| 557 }; | 567 }; |
| LEFT | RIGHT |