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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 * @type {Map.<string,Filter>} | 163 * @type {Map.<string,Filter>} |
164 */ | 164 */ |
165 Filter.knownFilters = new Map(); | 165 Filter.knownFilters = new Map(); |
166 | 166 |
167 /** | 167 /** |
168 * Regular expression that content filters should match | 168 * Regular expression that content filters should match |
169 * @type {RegExp} | 169 * @type {RegExp} |
170 */ | 170 */ |
171 Filter.contentRegExp = /^([^/*|@"!]*?)#([@?$])?#(.+)$/; | 171 Filter.contentRegExp = /^([^/*|@"!]*?)#([@?$])?#(.+)$/; |
172 /** | 172 /** |
173 * Regular expression that RegExp filters specified as RegExps should match | |
174 * @type {RegExp} | |
175 */ | |
176 Filter.regexpRegExp = /^(@@)?\/.*\/(?:\$~?[\w-]+(?:=[^,\s]+)?(?:,~?[\w-]+(?:=[^,
\s]+)?)*)?$/; | |
177 /** | |
178 * Regular expression that options on a RegExp filter should match | 173 * Regular expression that options on a RegExp filter should match |
179 * @type {RegExp} | 174 * @type {RegExp} |
180 */ | 175 */ |
181 Filter.optionsRegExp = /\$(~?[\w-]+(?:=[^,]*)?(?:,~?[\w-]+(?:=[^,]*)?)*)$/; | 176 Filter.optionsRegExp = /\$(~?[\w-]+(?:=[^,]*)?(?:,~?[\w-]+(?:=[^,]*)?)*)$/; |
182 /** | 177 /** |
183 * Regular expression that matches an invalid Content Security Policy | 178 * Regular expression that matches an invalid Content Security Policy |
184 * @type {RegExp} | 179 * @type {RegExp} |
185 */ | 180 */ |
186 Filter.invalidCSPRegExp = /(;|^) ?(base-uri|referrer|report-to|report-uri|upgrad
e-insecure-requests)\b/i; | 181 Filter.invalidCSPRegExp = /(;|^) ?(base-uri|referrer|report-to|report-uri|upgrad
e-insecure-requests)\b/i; |
187 | 182 |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 { | 676 { |
682 // The filter is a regular expression - convert it immediately to | 677 // The filter is a regular expression - convert it immediately to |
683 // catch syntax errors | 678 // catch syntax errors |
684 let regexp = new RegExp(regexpSource.substr(1, regexpSource.length - 2), | 679 let regexp = new RegExp(regexpSource.substr(1, regexpSource.length - 2), |
685 this.matchCase ? "" : "i"); | 680 this.matchCase ? "" : "i"); |
686 Object.defineProperty(this, "regexp", {value: regexp}); | 681 Object.defineProperty(this, "regexp", {value: regexp}); |
687 } | 682 } |
688 else | 683 else |
689 { | 684 { |
690 // No need to convert this filter to regular expression yet, do it on demand | 685 // No need to convert this filter to regular expression yet, do it on demand |
691 this.regexpSource = regexpSource; | 686 this.pattern = regexpSource; |
692 } | 687 } |
693 } | 688 } |
694 exports.RegExpFilter = RegExpFilter; | 689 exports.RegExpFilter = RegExpFilter; |
695 | 690 |
696 RegExpFilter.prototype = extend(ActiveFilter, { | 691 RegExpFilter.prototype = extend(ActiveFilter, { |
697 /** | 692 /** |
698 * @see ActiveFilter.domainSourceIsLowerCase | 693 * @see ActiveFilter.domainSourceIsLowerCase |
699 */ | 694 */ |
700 domainSourceIsLowerCase: true, | 695 domainSourceIsLowerCase: true, |
701 | 696 |
(...skipping 14 matching lines...) Expand all Loading... |
716 }, | 711 }, |
717 | 712 |
718 /** | 713 /** |
719 * @see ActiveFilter.domainSeparator | 714 * @see ActiveFilter.domainSeparator |
720 */ | 715 */ |
721 domainSeparator: "|", | 716 domainSeparator: "|", |
722 | 717 |
723 /** | 718 /** |
724 * Expression from which a regular expression should be generated - | 719 * Expression from which a regular expression should be generated - |
725 * for delayed creation of the regexp property | 720 * for delayed creation of the regexp property |
726 * @type {string} | 721 * @type {?string} |
727 */ | 722 */ |
728 regexpSource: null, | 723 pattern: null, |
729 /** | 724 /** |
730 * Regular expression to be used when testing against this filter | 725 * Regular expression to be used when testing against this filter |
731 * @type {RegExp} | 726 * @type {RegExp} |
732 */ | 727 */ |
733 get regexp() | 728 get regexp() |
734 { | 729 { |
735 let source = filterToRegExp(this.regexpSource, this.rewrite != null); | 730 let source = filterToRegExp(this.pattern, this.rewrite != null); |
736 let regexp = new RegExp(source, this.matchCase ? "" : "i"); | 731 let regexp = new RegExp(source, this.matchCase ? "" : "i"); |
737 Object.defineProperty(this, "regexp", {value: regexp}); | 732 Object.defineProperty(this, "regexp", {value: regexp}); |
738 this.regexpSource = null; | |
739 return regexp; | 733 return regexp; |
740 }, | 734 }, |
741 /** | 735 /** |
742 * Content types the filter applies to, combination of values from | 736 * Content types the filter applies to, combination of values from |
743 * RegExpFilter.typeMap | 737 * RegExpFilter.typeMap |
744 * @type {number} | 738 * @type {number} |
745 */ | 739 */ |
746 contentType: 0x7FFFFFFF, | 740 contentType: 0x7FFFFFFF, |
747 /** | 741 /** |
748 * Defines whether the filter should distinguish between lower and | 742 * Defines whether the filter should distinguish between lower and |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 | 1250 |
1257 /** | 1251 /** |
1258 * Script that should be executed | 1252 * Script that should be executed |
1259 * @type {string} | 1253 * @type {string} |
1260 */ | 1254 */ |
1261 get script() | 1255 get script() |
1262 { | 1256 { |
1263 return this.body; | 1257 return this.body; |
1264 } | 1258 } |
1265 }); | 1259 }); |
OLD | NEW |