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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 /** @module filterValidation */ | 18 /** @module filterValidation */ |
19 | 19 |
20 "use strict"; | 20 "use strict"; |
21 | 21 |
22 const {Filter, InvalidFilter, ElemHideBase} = require("filterClasses"); | 22 const {Filter, InvalidFilter, ElemHideBase, ElemHideEmulationFilter} = |
| 23 require("filterClasses"); |
23 const {Utils} = require("utils"); | 24 const {Utils} = require("utils"); |
24 | 25 |
25 /** | 26 /** |
26 * An error returned by | 27 * An error returned by |
27 * {@link module:filterValidation.parseFilter parseFilter()} or | 28 * {@link module:filterValidation.parseFilter parseFilter()} or |
28 * {@link module:filterValidation.parseFilters parseFilters()} | 29 * {@link module:filterValidation.parseFilters parseFilters()} |
29 * indicating that a given filter cannot be parsed, | 30 * indicating that a given filter cannot be parsed, |
30 * contains an invalid CSS selector or is a filter list header. | 31 * contains an invalid CSS selector or is a filter list header. |
31 * | 32 * |
32 * @param {string} type See documentation in the constructor below. | 33 * @param {string} type See documentation in the constructor below. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 if (text[0] == "[") | 136 if (text[0] == "[") |
136 return {error: new FilterParsingError("unexpected-filter-list-header")}; | 137 return {error: new FilterParsingError("unexpected-filter-list-header")}; |
137 | 138 |
138 filter = Filter.fromText(text); | 139 filter = Filter.fromText(text); |
139 | 140 |
140 if (filter instanceof InvalidFilter) | 141 if (filter instanceof InvalidFilter) |
141 { | 142 { |
142 return {error: new FilterParsingError("invalid-filter", | 143 return {error: new FilterParsingError("invalid-filter", |
143 {reason: filter.reason})}; | 144 {reason: filter.reason})}; |
144 } | 145 } |
145 if (filter instanceof ElemHideBase && !isValidCSSSelector(filter.selector)) | 146 if (filter instanceof ElemHideBase && |
| 147 !(filter instanceof ElemHideEmulationFilter) && |
| 148 !isValidCSSSelector(filter.selector)) |
146 { | 149 { |
147 return {error: new FilterParsingError("invalid-css-selector", | 150 return {error: new FilterParsingError("invalid-css-selector", |
148 {selector: filter.selector})}; | 151 {selector: filter.selector})}; |
149 } | 152 } |
150 } | 153 } |
151 | 154 |
152 return {filter}; | 155 return {filter}; |
153 }; | 156 }; |
154 | 157 |
155 /** | 158 /** |
(...skipping 25 matching lines...) Expand all Loading... |
181 | 184 |
182 if (error) | 185 if (error) |
183 { | 186 { |
184 error.lineno = i + 1; | 187 error.lineno = i + 1; |
185 errors.push(error); | 188 errors.push(error); |
186 } | 189 } |
187 } | 190 } |
188 | 191 |
189 return {filters, errors}; | 192 return {filters, errors}; |
190 }; | 193 }; |
OLD | NEW |