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

Side by Side Diff: lib/filterClasses.js

Issue 29863644: Issue 6870 - Remove support for legacy :-abp-properties() syntax (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Add check for legacy syntax and return of InvalidFilter Created Aug. 25, 2018, 5:29 a.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 | « no previous file | test/filterClasses.js » ('j') | test/filterClasses.js » ('J')
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-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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 * basic parsing and calls the right constructor then. 115 * basic parsing and calls the right constructor then.
116 * 116 *
117 * @param {string} text as in Filter() 117 * @param {string} text as in Filter()
118 * @return {Filter} 118 * @return {Filter}
119 */ 119 */
120 Filter.fromText = function(text) 120 Filter.fromText = function(text)
121 { 121 {
122 let filter = Filter.knownFilters.get(text); 122 let filter = Filter.knownFilters.get(text);
123 if (filter) 123 if (filter)
124 return filter; 124 return filter;
125 if (/\[-abp-properties=(["'])([^"']+)\1\]/i.test(text))
Manish Jethani 2018/08/25 07:31:10 This would be nice to do, but we simply cannot aff
Jon Sonesen 2018/08/27 21:32:21 Done.
126 return new InvalidFilter(text, "filter_unknown_option");
125 127
126 let match = text.includes("#") ? Filter.contentRegExp.exec(text) : null; 128 let match = text.includes("#") ? Filter.contentRegExp.exec(text) : null;
127 if (match) 129 if (match)
128 {
129 let propsMatch;
130 if (!match[2] && match[3].includes("[-") &&
131 (propsMatch = /\[-abp-properties=(["'])([^"']+)\1\]/.exec(match[3])))
132 {
133 // This is legacy CSS properties syntax, convert to current syntax
134 let prefix = match[3].substr(0, propsMatch.index);
135 let expression = propsMatch[2];
136 let suffix = match[3].substr(propsMatch.index + propsMatch[0].length);
137 return Filter.fromText(`${match[1]}#?#` +
138 `${prefix}:-abp-properties(${expression})${suffix}`);
139 }
140
141 filter = ContentFilter.fromText(text, match[1], match[2], match[3]); 130 filter = ContentFilter.fromText(text, match[1], match[2], match[3]);
142 }
143 else if (text[0] == "!") 131 else if (text[0] == "!")
144 filter = new CommentFilter(text); 132 filter = new CommentFilter(text);
145 else 133 else
146 filter = RegExpFilter.fromText(text); 134 filter = RegExpFilter.fromText(text);
147 135
148 Filter.knownFilters.set(filter.text, filter); 136 Filter.knownFilters.set(filter.text, filter);
149 return filter; 137 return filter;
150 }; 138 };
151 139
152 /** 140 /**
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 1175
1188 /** 1176 /**
1189 * Script that should be executed 1177 * Script that should be executed
1190 * @type {string} 1178 * @type {string}
1191 */ 1179 */
1192 get script() 1180 get script()
1193 { 1181 {
1194 return this.body; 1182 return this.body;
1195 } 1183 }
1196 }); 1184 });
OLDNEW
« no previous file with comments | « no previous file | test/filterClasses.js » ('j') | test/filterClasses.js » ('J')

Powered by Google App Engine
This is Rietveld