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: Check whitelist for whitelist-only types Created Oct. 21, 2018, 2:43 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 // If the type mask includes no types other than whitelist-only types, we
337 // can skip the blacklist.
336 if ((typeMask & ~WHITELIST_ONLY_TYPES) != 0) 338 if ((typeMask & ~WHITELIST_ONLY_TYPES) != 0)
Manish Jethani 2018/10/21 15:00:23 If the type mask includes no types other than DOCU
337 { 339 {
338 for (let i = 0, l = candidates.length; i < l; i++) 340 for (let i = 0, l = candidates.length; !blacklistHit && i < l; i++)
339 { 341 {
340 let substr = candidates[i]; 342 blacklistHit = this.blacklist._checkEntryMatch(candidates[i], location,
341 blacklistHit = this.blacklist._checkEntryMatch( 343 typeMask, docDomain,
342 substr, location, typeMask, docDomain, thirdParty, sitekey, 344 thirdParty, sitekey,
343 specificOnly 345 specificOnly);
344 );
345 if (blacklistHit)
346 break;
347 } 346 }
348 } 347 }
349 348
349 // If the type mask includes any whitelist-only types, we need to check the
350 // whitelist.
350 if (blacklistHit || (typeMask & WHITELIST_ONLY_TYPES) != 0) 351 if (blacklistHit || (typeMask & WHITELIST_ONLY_TYPES) != 0)
Manish Jethani 2018/10/21 15:00:22 If the type mask includes DOCUMENT, ELEMHIDE, GENE
351 { 352 {
352 for (let i = 0, l = candidates.length; i < l; i++) 353 for (let i = 0, l = candidates.length; !whitelistHit && i < l; i++)
353 { 354 {
354 let substr = candidates[i]; 355 whitelistHit = this.whitelist._checkEntryMatch(candidates[i], location,
355 whitelistHit = this.whitelist._checkEntryMatch( 356 typeMask, docDomain,
356 substr, location, typeMask, docDomain, thirdParty, sitekey 357 thirdParty, sitekey);
357 );
358 if (whitelistHit)
359 break;
360 } 358 }
361 } 359 }
362 360
363 return whitelistHit || blacklistHit; 361 return whitelistHit || blacklistHit;
364 } 362 }
365 363
366 /** 364 /**
367 * @see Matcher#matchesAny 365 * @see Matcher#matchesAny
368 * @inheritdoc 366 * @inheritdoc
369 */ 367 */
(...skipping 20 matching lines...) Expand all
390 388
391 exports.CombinedMatcher = CombinedMatcher; 389 exports.CombinedMatcher = CombinedMatcher;
392 390
393 /** 391 /**
394 * Shared {@link CombinedMatcher} instance that should usually be used. 392 * Shared {@link CombinedMatcher} instance that should usually be used.
395 * @type {CombinedMatcher} 393 * @type {CombinedMatcher}
396 */ 394 */
397 let defaultMatcher = new CombinedMatcher(); 395 let defaultMatcher = new CombinedMatcher();
398 396
399 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