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-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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 specificOnly) | 326 specificOnly) |
327 { | 327 { |
328 let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g); | 328 let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g); |
329 if (candidates === null) | 329 if (candidates === null) |
330 candidates = []; | 330 candidates = []; |
331 candidates.push(""); | 331 candidates.push(""); |
332 | 332 |
333 let whitelistHit = null; | 333 let whitelistHit = null; |
334 let blacklistHit = null; | 334 let blacklistHit = null; |
335 | 335 |
336 let {blacklist, whitelist} = this; | 336 // If the type mask includes no types other than whitelist-only types, we |
337 | 337 // can skip the blacklist. |
338 if ((typeMask & ~WHITELIST_ONLY_TYPES) != 0) | 338 if ((typeMask & ~WHITELIST_ONLY_TYPES) != 0) |
339 { | 339 { |
340 for (let i = 0, l = candidates.length; !blacklistHit && i < l; i++) | 340 for (let i = 0, l = candidates.length; !blacklistHit && i < l; i++) |
341 { | 341 { |
342 blacklistHit = blacklist._checkEntryMatch(candidates[i], location, | 342 blacklistHit = this.blacklist._checkEntryMatch(candidates[i], location, |
343 typeMask, docDomain, | 343 typeMask, docDomain, |
344 thirdParty, sitekey, | 344 thirdParty, sitekey, |
345 specificOnly); | 345 specificOnly); |
346 } | 346 } |
347 } | 347 } |
348 | 348 |
| 349 // If the type mask includes any whitelist-only types, we need to check the |
| 350 // whitelist. |
349 if (blacklistHit || (typeMask & WHITELIST_ONLY_TYPES) != 0) | 351 if (blacklistHit || (typeMask & WHITELIST_ONLY_TYPES) != 0) |
350 { | 352 { |
351 for (let i = 0, l = candidates.length; !whitelistHit && i < l; i++) | 353 for (let i = 0, l = candidates.length; !whitelistHit && i < l; i++) |
352 { | 354 { |
353 whitelistHit = whitelist._checkEntryMatch(candidates[i], location, | 355 whitelistHit = this.whitelist._checkEntryMatch(candidates[i], location, |
354 typeMask, docDomain, | 356 typeMask, docDomain, |
355 thirdParty, sitekey); | 357 thirdParty, sitekey); |
356 } | 358 } |
357 } | 359 } |
358 | 360 |
359 return whitelistHit || blacklistHit; | 361 return whitelistHit || blacklistHit; |
360 } | 362 } |
361 | 363 |
362 /** | 364 /** |
363 * @see Matcher#matchesAny | 365 * @see Matcher#matchesAny |
364 * @inheritdoc | 366 * @inheritdoc |
365 */ | 367 */ |
(...skipping 20 matching lines...) Expand all Loading... |
386 | 388 |
387 exports.CombinedMatcher = CombinedMatcher; | 389 exports.CombinedMatcher = CombinedMatcher; |
388 | 390 |
389 /** | 391 /** |
390 * Shared {@link CombinedMatcher} instance that should usually be used. | 392 * Shared {@link CombinedMatcher} instance that should usually be used. |
391 * @type {CombinedMatcher} | 393 * @type {CombinedMatcher} |
392 */ | 394 */ |
393 let defaultMatcher = new CombinedMatcher(); | 395 let defaultMatcher = new CombinedMatcher(); |
394 | 396 |
395 exports.defaultMatcher = defaultMatcher; | 397 exports.defaultMatcher = defaultMatcher; |
LEFT | RIGHT |