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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 domainSource: null, | 440 domainSource: null, |
441 | 441 |
442 /** | 442 /** |
443 * Separator character used in domainSource property, must be | 443 * Separator character used in domainSource property, must be |
444 * overridden by subclasses | 444 * overridden by subclasses |
445 * @type {string} | 445 * @type {string} |
446 */ | 446 */ |
447 domainSeparator: null, | 447 domainSeparator: null, |
448 | 448 |
449 /** | 449 /** |
450 * Determines whether domainSource is already lower-case, | |
451 * can be overridden by subclasses. | |
452 * @type {boolean} | |
453 */ | |
454 domainSourceIsLowerCase: false, | |
455 | |
456 /** | |
457 * Map containing domains that this filter should match on/not match | 450 * Map containing domains that this filter should match on/not match |
458 * on or null if the filter should match on all domains | 451 * on or null if the filter should match on all domains |
459 * @type {?Map.<string,boolean>} | 452 * @type {?Map.<string,boolean>} |
460 */ | 453 */ |
461 get domains() | 454 get domains() |
462 { | 455 { |
463 let domains = null; | 456 let domains = null; |
464 | 457 |
465 if (this.domainSource) | 458 if (this.domainSource) |
466 { | 459 { |
467 let source = this.domainSource; | 460 let source = this.domainSource.toLowerCase(); |
Jon Sonesen
2018/09/07 03:09:33
Im super happy to see things like this go away heh
Manish Jethani
2018/09/07 03:42:44
I'm guessing "historical reasons." It may have bee
Jon Sonesen
2018/09/17 18:11:33
Yeah makes sense, thanks for explaining. I tested
Sebastian Noack
2018/09/17 19:20:59
This was an optimization at some point, but indeed
| |
468 if (!this.domainSourceIsLowerCase) | |
469 { | |
470 // RegExpFilter already have lowercase domains | |
471 source = source.toLowerCase(); | |
472 } | |
473 | 461 |
474 let knownMap = knownDomainMaps.get(source); | 462 let knownMap = knownDomainMaps.get(source); |
475 if (knownMap) | 463 if (knownMap) |
476 { | 464 { |
477 domains = knownMap; | 465 domains = knownMap; |
478 } | 466 } |
479 else | 467 else |
480 { | 468 { |
481 let list = source.split(this.domainSeparator); | 469 let list = source.split(this.domainSeparator); |
482 if (list.length == 1 && list[0][0] != "~") | 470 if (list.length == 1 && list[0][0] != "~") |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
683 else | 671 else |
684 { | 672 { |
685 // No need to convert this filter to regular expression yet, do it on demand | 673 // No need to convert this filter to regular expression yet, do it on demand |
686 this.pattern = regexpSource; | 674 this.pattern = regexpSource; |
687 } | 675 } |
688 } | 676 } |
689 exports.RegExpFilter = RegExpFilter; | 677 exports.RegExpFilter = RegExpFilter; |
690 | 678 |
691 RegExpFilter.prototype = extend(ActiveFilter, { | 679 RegExpFilter.prototype = extend(ActiveFilter, { |
692 /** | 680 /** |
693 * @see ActiveFilter.domainSourceIsLowerCase | |
694 */ | |
695 domainSourceIsLowerCase: true, | |
696 | |
697 /** | |
698 * Number of filters contained, will always be 1 (required to | 681 * Number of filters contained, will always be 1 (required to |
699 * optimize {@link Matcher}). | 682 * optimize {@link Matcher}). |
700 * @type {number} | 683 * @type {number} |
701 */ | 684 */ |
702 length: 1, | 685 length: 1, |
703 | 686 |
704 /** | 687 /** |
705 * The filter itself (required to optimize {@link Matcher}). | 688 * The filter itself (required to optimize {@link Matcher}). |
706 * @type {RegExpFilter} | 689 * @type {RegExpFilter} |
707 */ | 690 */ |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
862 else | 845 else |
863 { | 846 { |
864 switch (option.toLowerCase()) | 847 switch (option.toLowerCase()) |
865 { | 848 { |
866 case "match-case": | 849 case "match-case": |
867 matchCase = !inverse; | 850 matchCase = !inverse; |
868 break; | 851 break; |
869 case "domain": | 852 case "domain": |
870 if (!value) | 853 if (!value) |
871 return new InvalidFilter(origText, "filter_unknown_option"); | 854 return new InvalidFilter(origText, "filter_unknown_option"); |
872 domains = value.toLowerCase(); | 855 domains = value; |
873 break; | 856 break; |
874 case "third-party": | 857 case "third-party": |
875 thirdParty = !inverse; | 858 thirdParty = !inverse; |
876 break; | 859 break; |
877 case "collapse": | 860 case "collapse": |
878 collapse = !inverse; | 861 collapse = !inverse; |
879 break; | 862 break; |
880 case "sitekey": | 863 case "sitekey": |
881 if (!value) | 864 if (!value) |
882 return new InvalidFilter(origText, "filter_unknown_option"); | 865 return new InvalidFilter(origText, "filter_unknown_option"); |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1247 | 1230 |
1248 /** | 1231 /** |
1249 * Script that should be executed | 1232 * Script that should be executed |
1250 * @type {string} | 1233 * @type {string} |
1251 */ | 1234 */ |
1252 get script() | 1235 get script() |
1253 { | 1236 { |
1254 return this.body; | 1237 return this.body; |
1255 } | 1238 } |
1256 }); | 1239 }); |
OLD | NEW |