| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 * matching filters to the list; if omitted, the function directly returns | 305 * matching filters to the list; if omitted, the function directly returns |
| 306 * the first matching filter. | 306 * the first matching filter. |
| 307 * @returns {?Filter} | 307 * @returns {?Filter} |
| 308 * @protected | 308 * @protected |
| 309 */ | 309 */ |
| 310 checkEntryMatch(keyword, location, typeMask, docDomain, thirdParty, sitekey, | 310 checkEntryMatch(keyword, location, typeMask, docDomain, thirdParty, sitekey, |
| 311 specificOnly, collection) | 311 specificOnly, collection) |
| 312 { | 312 { |
| 313 // We need to skip the simple (location-only) filters if the type mask does | 313 // We need to skip the simple (location-only) filters if the type mask does |
| 314 // not contain any default content types. | 314 // not contain any default content types. |
| 315 if ((typeMask & DEFAULT_TYPES) != 0) | 315 if (!specificOnly && (typeMask & DEFAULT_TYPES) != 0) |
|
Manish Jethani
2019/02/06 11:18:20
These are all generic filters so the code should n
| |
| 316 { | 316 { |
| 317 let simpleSet = this._simpleFiltersByKeyword.get(keyword); | 317 let simpleSet = this._simpleFiltersByKeyword.get(keyword); |
| 318 if (simpleSet) | 318 if (simpleSet) |
| 319 { | 319 { |
| 320 let lowerCaseLocation = location.toLowerCase(); | 320 let lowerCaseLocation = location.toLowerCase(); |
| 321 | 321 |
| 322 for (let filter of simpleSet) | 322 for (let filter of simpleSet) |
| 323 { | 323 { |
| 324 if (specificOnly && !(filter instanceof WhitelistFilter)) | |
| 325 continue; | |
| 326 | |
| 327 if (filter.matchesLocation(location, lowerCaseLocation)) | 324 if (filter.matchesLocation(location, lowerCaseLocation)) |
| 328 { | 325 { |
| 329 if (!collection) | 326 if (!collection) |
| 330 return filter; | 327 return filter; |
| 331 | 328 |
| 332 collection.push(filter); | 329 collection.push(filter); |
| 333 } | 330 } |
| 334 } | 331 } |
| 335 } | 332 } |
| 336 } | 333 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 350 } | 347 } |
| 351 else | 348 else |
| 352 { | 349 { |
| 353 complexSet = this._complexFiltersByKeyword.get(keyword); | 350 complexSet = this._complexFiltersByKeyword.get(keyword); |
| 354 } | 351 } |
| 355 | 352 |
| 356 if (complexSet) | 353 if (complexSet) |
| 357 { | 354 { |
| 358 for (let filter of complexSet) | 355 for (let filter of complexSet) |
| 359 { | 356 { |
| 360 if (specificOnly && filter.isGeneric() && | 357 if (specificOnly && filter.isGeneric()) |
| 361 !(filter instanceof WhitelistFilter)) | |
|
Manish Jethani
2019/02/06 11:18:20
It's up to the caller to not pass the specific-onl
hub
2019/02/06 15:46:44
I tend to think we should protect ourselves from t
Manish Jethani
2019/02/06 16:16:00
Yeah, but my point was that we should not expose t
hub
2019/02/06 17:47:56
Fair enough.
| |
| 362 continue; | 358 continue; |
| 363 | 359 |
| 364 if (filter.matches(location, typeMask, docDomain, thirdParty, sitekey)) | 360 if (filter.matches(location, typeMask, docDomain, thirdParty, sitekey)) |
| 365 { | 361 { |
| 366 if (!collection) | 362 if (!collection) |
| 367 return filter; | 363 return filter; |
| 368 | 364 |
| 369 collection.push(filter); | 365 collection.push(filter); |
| 370 } | 366 } |
| 371 } | 367 } |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 667 | 663 |
| 668 return result; | 664 return result; |
| 669 } | 665 } |
| 670 | 666 |
| 671 /** | 667 /** |
| 672 * Tests whether the URL is whitelisted | 668 * Tests whether the URL is whitelisted |
| 673 * @see Matcher#matchesAny | 669 * @see Matcher#matchesAny |
| 674 * @inheritdoc | 670 * @inheritdoc |
| 675 * @returns {boolean} | 671 * @returns {boolean} |
| 676 */ | 672 */ |
| 677 isWhitelisted(location, typeMask, docDomain, thirdParty, sitekey, | 673 isWhitelisted(location, typeMask, docDomain, thirdParty, sitekey) |
| 678 specificOnly) | |
| 679 { | 674 { |
| 680 return !!this._whitelist.matchesAny(location, typeMask, docDomain, | 675 return !!this._whitelist.matchesAny(location, typeMask, docDomain, |
| 681 thirdParty, sitekey, specificOnly); | 676 thirdParty, sitekey); |
| 682 } | 677 } |
| 683 } | 678 } |
| 684 | 679 |
| 685 exports.CombinedMatcher = CombinedMatcher; | 680 exports.CombinedMatcher = CombinedMatcher; |
| 686 | 681 |
| 687 /** | 682 /** |
| 688 * Shared {@link CombinedMatcher} instance that should usually be used. | 683 * Shared {@link CombinedMatcher} instance that should usually be used. |
| 689 * @type {CombinedMatcher} | 684 * @type {CombinedMatcher} |
| 690 */ | 685 */ |
| 691 let defaultMatcher = new CombinedMatcher(); | 686 let defaultMatcher = new CombinedMatcher(); |
| 692 | 687 |
| 693 exports.defaultMatcher = defaultMatcher; | 688 exports.defaultMatcher = defaultMatcher; |
| OLD | NEW |