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

Delta Between Two Patch Sets: lib/matcher.js

Issue 30000586: Issue 7265 - Orgnanize request blocking filters by domain (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created Feb. 6, 2019, 3:19 p.m.
Right Patch Set: Rebase Created Feb. 7, 2019, 3:45 a.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 | « lib/filterClasses.js ('k') | test/filterClasses.js » ('j') | 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 300
301 let filtersByDomain = this._filterDomainMapsByKeyword.get(keyword); 301 let filtersByDomain = this._filterDomainMapsByKeyword.get(keyword);
302 if (filtersByDomain) 302 if (filtersByDomain)
303 { 303 {
304 let domains = filter.domains || defaultDomains; 304 let domains = filter.domains || defaultDomains;
305 for (let domain of domains.keys()) 305 for (let domain of domains.keys())
306 { 306 {
307 let map = filtersByDomain.get(domain); 307 let map = filtersByDomain.get(domain);
308 if (map) 308 if (map)
309 { 309 {
310 if (map.size > 1 || map instanceof Map) 310 if (map.size > 1 || map instanceof Map)
Sebastian Noack 2019/02/06 16:30:58 In which scenario would "map" not be a Map object,
Manish Jethani 2019/02/06 19:25:05 It's a hack. The filter object doubles up as a fa
311 { 311 {
312 map.delete(filter); 312 map.delete(filter);
313 313
314 if (map.size == 0) 314 if (map.size == 0)
315 filtersByDomain.delete(domain); 315 filtersByDomain.delete(domain);
316 } 316 }
317 else if (filter == map) 317 else if (filter == map)
318 { 318 {
319 filtersByDomain.delete(domain); 319 filtersByDomain.delete(domain);
320 } 320 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 * matching filters to the list; if omitted, the function directly returns 479 * matching filters to the list; if omitted, the function directly returns
480 * the first matching filter. 480 * the first matching filter.
481 * @returns {?Filter} 481 * @returns {?Filter}
482 * @protected 482 * @protected
483 */ 483 */
484 checkEntryMatch(keyword, location, typeMask, docDomain, thirdParty, sitekey, 484 checkEntryMatch(keyword, location, typeMask, docDomain, thirdParty, sitekey,
485 specificOnly, collection) 485 specificOnly, collection)
486 { 486 {
487 // We need to skip the simple (location-only) filters if the type mask does 487 // We need to skip the simple (location-only) filters if the type mask does
488 // not contain any default content types. 488 // not contain any default content types.
489 if ((typeMask & DEFAULT_TYPES) != 0) 489 if (!specificOnly && (typeMask & DEFAULT_TYPES) != 0)
490 { 490 {
491 let filter = this._checkEntryMatchSimple(keyword, location, typeMask, 491 let filter = this._checkEntryMatchSimple(keyword, location, typeMask,
492 docDomain, thirdParty, sitekey, 492 docDomain, thirdParty, sitekey,
493 specificOnly, collection); 493 specificOnly, collection);
494 if (filter) 494 if (filter)
495 return filter; 495 return filter;
496 } 496 }
497 497
498 // If the type mask contains a non-default type (first condition) and it is 498 // If the type mask contains a non-default type (first condition) and it is
499 // the only type in the mask (second condition), we can use the 499 // the only type in the mask (second condition), we can use the
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 805
806 return result; 806 return result;
807 } 807 }
808 808
809 /** 809 /**
810 * Tests whether the URL is whitelisted 810 * Tests whether the URL is whitelisted
811 * @see Matcher#matchesAny 811 * @see Matcher#matchesAny
812 * @inheritdoc 812 * @inheritdoc
813 * @returns {boolean} 813 * @returns {boolean}
814 */ 814 */
815 isWhitelisted(location, typeMask, docDomain, thirdParty, sitekey, 815 isWhitelisted(location, typeMask, docDomain, thirdParty, sitekey)
816 specificOnly)
817 { 816 {
818 return !!this._whitelist.matchesAny(location, typeMask, docDomain, 817 return !!this._whitelist.matchesAny(location, typeMask, docDomain,
819 thirdParty, sitekey, specificOnly); 818 thirdParty, sitekey);
820 } 819 }
821 } 820 }
822 821
823 exports.CombinedMatcher = CombinedMatcher; 822 exports.CombinedMatcher = CombinedMatcher;
824 823
825 /** 824 /**
826 * Shared {@link CombinedMatcher} instance that should usually be used. 825 * Shared {@link CombinedMatcher} instance that should usually be used.
827 * @type {CombinedMatcher} 826 * @type {CombinedMatcher}
828 */ 827 */
829 let defaultMatcher = new CombinedMatcher(); 828 let defaultMatcher = new CombinedMatcher();
830 829
831 exports.defaultMatcher = defaultMatcher; 830 exports.defaultMatcher = defaultMatcher;
LEFTRIGHT

Powered by Google App Engine
This is Rietveld