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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 /** | 80 /** |
81 * Cache for known filters, maps string representation to filter objects. | 81 * Cache for known filters, maps string representation to filter objects. |
82 * @type {Map.<string,Filter>} | 82 * @type {Map.<string,Filter>} |
83 */ | 83 */ |
84 Filter.knownFilters = new Map(); | 84 Filter.knownFilters = new Map(); |
85 | 85 |
86 /** | 86 /** |
87 * Regular expression that element hiding filters should match | 87 * Regular expression that element hiding filters should match |
88 * @type {RegExp} | 88 * @type {RegExp} |
89 */ | 89 */ |
90 Filter.elemhideRegExp = /^([^/*|@"!]*?)#([@?])?#(.+)$/; | 90 Filter.elemhideRegExp = /^([^/*|@"!?]*?)#([@?])?#(.+)$/; |
91 /** | 91 /** |
92 * Regular expression that RegExp filters specified as RegExps should match | 92 * Regular expression that RegExp filters specified as RegExps should match |
93 * @type {RegExp} | 93 * @type {RegExp} |
94 */ | 94 */ |
95 Filter.regexpRegExp = /^(@@)?\/.*\/(?:\$~?[\w-]+(?:=[^,\s]+)?(?:,~?[\w-]+(?:=[^,
\s]+)?)*)?$/; | 95 Filter.regexpRegExp = /^(@@)?\/.*\/(?:\$~?[\w-]+(?:=[^,\s]+)?(?:,~?[\w-]+(?:=[^,
\s]+)?)*)?$/; |
96 /** | 96 /** |
97 * Regular expression that options on a RegExp filter should match | 97 * Regular expression that options on a RegExp filter should match |
98 * @type {RegExp} | 98 * @type {RegExp} |
99 */ | 99 */ |
100 Filter.optionsRegExp = /\$(~?[\w-]+(?:=[^,]+)?(?:,~?[\w-]+(?:=[^,]+)?)*)$/; | 100 Filter.optionsRegExp = /\$(~?[\w-]+(?:=[^,]+)?(?:,~?[\w-]+(?:=[^,]+)?)*)$/; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 text = text.replace(/[^\S ]+/g, ""); | 181 text = text.replace(/[^\S ]+/g, ""); |
182 | 182 |
183 // Don't remove spaces inside comments | 183 // Don't remove spaces inside comments |
184 if (/^ *!/.test(text)) | 184 if (/^ *!/.test(text)) |
185 return text.trim(); | 185 return text.trim(); |
186 | 186 |
187 // Special treatment for element hiding filters, right side is allowed to | 187 // Special treatment for element hiding filters, right side is allowed to |
188 // contain spaces | 188 // contain spaces |
189 if (Filter.elemhideRegExp.test(text)) | 189 if (Filter.elemhideRegExp.test(text)) |
190 { | 190 { |
191 let [, domain, separator, selector] = /^(.*?)(#@?#?)(.*)$/.exec(text); | 191 let [, domain, separator, selector] = /^(.*?)(#[@?]?#?)(.*)$/.exec(text); |
192 return domain.replace(/ +/g, "") + separator + selector.trim(); | 192 return domain.replace(/ +/g, "") + separator + selector.trim(); |
193 } | 193 } |
194 | 194 |
195 // For most regexp filters we strip all spaces, but $csp filter options | 195 // For most regexp filters we strip all spaces, but $csp filter options |
196 // are allowed to contain single (non trailing) spaces. | 196 // are allowed to contain single (non trailing) spaces. |
197 let strippedText = text.replace(/ +/g, ""); | 197 let strippedText = text.replace(/ +/g, ""); |
198 if (!strippedText.includes("$") || !/\bcsp=/i.test(strippedText)) | 198 if (!strippedText.includes("$") || !/\bcsp=/i.test(strippedText)) |
199 return strippedText; | 199 return strippedText; |
200 | 200 |
201 let optionsMatch = Filter.optionsRegExp.exec(strippedText); | 201 let optionsMatch = Filter.optionsRegExp.exec(strippedText); |
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 */ | 1080 */ |
1081 function ElemHideEmulationFilter(text, domains, selector) | 1081 function ElemHideEmulationFilter(text, domains, selector) |
1082 { | 1082 { |
1083 ElemHideBase.call(this, text, domains, selector); | 1083 ElemHideBase.call(this, text, domains, selector); |
1084 } | 1084 } |
1085 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; | 1085 exports.ElemHideEmulationFilter = ElemHideEmulationFilter; |
1086 | 1086 |
1087 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { | 1087 ElemHideEmulationFilter.prototype = extend(ElemHideBase, { |
1088 type: "elemhideemulation" | 1088 type: "elemhideemulation" |
1089 }); | 1089 }); |
OLD | NEW |