Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/filterValidation.js

Issue 29401596: Issue 5094 - Implement support for :has() in chrome extension (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Simplify patch to deal with latest version of the implementation Created May 4, 2017, 8:34 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « dependencies ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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} = require(" filterClasses");
kzar 2017/05/29 15:25:57 Nit: This line is now too long. (Did you check for
23 const {Utils} = require("utils"); 23 const {Utils} = require("utils");
24 24
25 /** 25 /**
26 * An error returned by 26 * An error returned by
27 * {@link module:filterValidation.parseFilter parseFilter()} or 27 * {@link module:filterValidation.parseFilter parseFilter()} or
28 * {@link module:filterValidation.parseFilters parseFilters()} 28 * {@link module:filterValidation.parseFilters parseFilters()}
29 * indicating that a given filter cannot be parsed, 29 * indicating that a given filter cannot be parsed,
30 * contains an invalid CSS selector or is a filter list header. 30 * contains an invalid CSS selector or is a filter list header.
31 * 31 *
32 * @param {string} type See documentation in the constructor below. 32 * @param {string} type See documentation in the constructor below.
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 if (text[0] == "[") 135 if (text[0] == "[")
136 return {error: new FilterParsingError("unexpected-filter-list-header")}; 136 return {error: new FilterParsingError("unexpected-filter-list-header")};
137 137
138 filter = Filter.fromText(text); 138 filter = Filter.fromText(text);
139 139
140 if (filter instanceof InvalidFilter) 140 if (filter instanceof InvalidFilter)
141 { 141 {
142 return {error: new FilterParsingError("invalid-filter", 142 return {error: new FilterParsingError("invalid-filter",
143 {reason: filter.reason})}; 143 {reason: filter.reason})};
144 } 144 }
145 if (filter instanceof ElemHideBase && !isValidCSSSelector(filter.selector)) 145 if (filter instanceof ElemHideBase &&
146 !filter instanceof ElemHideEmulationFilter &&
147 !isValidCSSSelector(filter.selector))
146 { 148 {
147 return {error: new FilterParsingError("invalid-css-selector", 149 return {error: new FilterParsingError("invalid-css-selector",
148 {selector: filter.selector})}; 150 {selector: filter.selector})};
149 } 151 }
150 } 152 }
151 153
152 return {filter}; 154 return {filter};
153 }; 155 };
154 156
155 /** 157 /**
(...skipping 25 matching lines...) Expand all
181 183
182 if (error) 184 if (error)
183 { 185 {
184 error.lineno = i + 1; 186 error.lineno = i + 1;
185 errors.push(error); 187 errors.push(error);
186 } 188 }
187 } 189 }
188 190
189 return {filters, errors}; 191 return {filters, errors};
190 }; 192 };
OLDNEW
« no previous file with comments | « dependencies ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld