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

Delta Between Two Patch Sets: lib/matcher.js

Issue 29896562: Issue 7003 - Look up whitelist filter only if URL is blocked (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Refactor a bit Created Oct. 21, 2018, 2:54 p.m.
Right Patch Set: Add comments Created Oct. 22, 2018, 9:14 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 | no next file » | 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-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
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
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;
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld