| Left: | ||
| Right: |
| 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 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 735 // catch syntax errors | 735 // catch syntax errors |
| 736 let regexp = new RegExp(regexpSource.substr(1, regexpSource.length - 2), | 736 let regexp = new RegExp(regexpSource.substr(1, regexpSource.length - 2), |
| 737 this.matchCase ? "" : "i"); | 737 this.matchCase ? "" : "i"); |
| 738 Object.defineProperty(this, "regexp", {value: regexp}); | 738 Object.defineProperty(this, "regexp", {value: regexp}); |
| 739 } | 739 } |
| 740 else | 740 else |
| 741 { | 741 { |
| 742 // Patterns like /foo/bar/* exist so that they are not treated as regular | 742 // Patterns like /foo/bar/* exist so that they are not treated as regular |
| 743 // expressions. We drop any superfluous wildcards here so our optimizations | 743 // expressions. We drop any superfluous wildcards here so our optimizations |
| 744 // can kick in. | 744 // can kick in. |
| 745 if (this.rewrite) | 745 regexpSource = regexpSource.replace(/^\*+/, "").replace(/\*+$/, ""); |
|
Manish Jethani
2019/04/16 05:52:58
This actually has a somewhat opposite of the inten
hub
2019/04/16 12:23:06
Good catch.
| |
| 746 regexpSource = regexpSource.replace(/^\*+/, "").replace(/\*+$/, ""); | |
| 747 | 746 |
| 748 if (!this.matchCase && isLiteralPattern(regexpSource)) | 747 if (!this.matchCase && isLiteralPattern(regexpSource)) |
| 749 regexpSource = regexpSource.toLowerCase(); | 748 regexpSource = regexpSource.toLowerCase(); |
| 750 | 749 |
| 751 // No need to convert this filter to regular expression yet, do it on demand | 750 // No need to convert this filter to regular expression yet, do it on demand |
| 752 this.pattern = regexpSource; | 751 this.pattern = regexpSource; |
| 753 } | 752 } |
| 754 } | 753 } |
| 755 exports.RegExpFilter = RegExpFilter; | 754 exports.RegExpFilter = RegExpFilter; |
| 756 | 755 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 828 } | 827 } |
| 829 | 828 |
| 830 Object.defineProperty( | 829 Object.defineProperty( |
| 831 this, "sitekeys", {value: sitekeys, enumerable: true} | 830 this, "sitekeys", {value: sitekeys, enumerable: true} |
| 832 ); | 831 ); |
| 833 return this.sitekeys; | 832 return this.sitekeys; |
| 834 }, | 833 }, |
| 835 | 834 |
| 836 /** | 835 /** |
| 837 * The name of the internal resource to which to rewrite the | 836 * The name of the internal resource to which to rewrite the |
| 838 * URL. e.g. if the value of the <code>rewrite</code> property is | 837 * URL. e.g. if the value of the <code>$rewrite</code> option is |
|
Manish Jethani
2019/04/16 05:52:58
I think we can replace `<code>rewrite</code> prope
hub
2019/04/16 12:23:06
Done.
| |
| 839 * <code>abp-resource:blank-html</code>, this should be | 838 * <code>abp-resource:blank-html</code>, this should be |
| 840 * <code>blank-html</code>. | 839 * <code>blank-html</code>. |
| 841 * @type {?string} | 840 * @type {?string} |
| 842 */ | 841 */ |
| 843 rewrite: null, | 842 rewrite: null, |
| 844 | 843 |
| 845 /** | 844 /** |
| 846 * Tests whether the URL matches this filter | 845 * Tests whether the URL matches this filter |
| 847 * @param {string} location URL to be tested | 846 * @param {string} location URL to be tested |
| 848 * @param {number} typeMask bitmask of content / request types to match | 847 * @param {number} typeMask bitmask of content / request types to match |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1037 break; | 1036 break; |
| 1038 case "collapse": | 1037 case "collapse": |
| 1039 collapse = !inverse; | 1038 collapse = !inverse; |
| 1040 break; | 1039 break; |
| 1041 case "sitekey": | 1040 case "sitekey": |
| 1042 if (!value) | 1041 if (!value) |
| 1043 return new InvalidFilter(origText, "filter_unknown_option"); | 1042 return new InvalidFilter(origText, "filter_unknown_option"); |
| 1044 sitekeys = value.toUpperCase(); | 1043 sitekeys = value.toUpperCase(); |
| 1045 break; | 1044 break; |
| 1046 case "rewrite": | 1045 case "rewrite": |
| 1047 if (!value || !value.startsWith("abp-resource:")) | 1046 if (value == null) |
|
Manish Jethani
2019/04/16 05:52:58
It doesn't matter _that_ much, but I'd just like t
hub
2019/04/16 12:23:06
I think I'm gonna go the safe route. Change was in
| |
| 1047 return new InvalidFilter(origText, "filter_unknown_option"); | |
| 1048 if (!value.startsWith("abp-resource:")) | |
| 1048 return new InvalidFilter(origText, "filter_invalid_rewrite"); | 1049 return new InvalidFilter(origText, "filter_invalid_rewrite"); |
| 1049 rewrite = value.substr("abp-resource:".length); | 1050 rewrite = value.substr("abp-resource:".length); |
| 1050 break; | 1051 break; |
| 1051 default: | 1052 default: |
| 1052 return new InvalidFilter(origText, "filter_unknown_option"); | 1053 return new InvalidFilter(origText, "filter_unknown_option"); |
| 1053 } | 1054 } |
| 1054 } | 1055 } |
| 1055 } | 1056 } |
| 1056 } | 1057 } |
| 1057 | 1058 |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1399 | 1400 |
| 1400 /** | 1401 /** |
| 1401 * Script that should be executed | 1402 * Script that should be executed |
| 1402 * @type {string} | 1403 * @type {string} |
| 1403 */ | 1404 */ |
| 1404 get script() | 1405 get script() |
| 1405 { | 1406 { |
| 1406 return this.body; | 1407 return this.body; |
| 1407 } | 1408 } |
| 1408 }); | 1409 }); |
| LEFT | RIGHT |