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

Side by Side Diff: lib/synchronizer.js

Issue 29873570: Issue 6923 - Only parse metadata from special comments at the top of the file (Closed)
Patch Set: Change end-of-metadata semantics Created Sept. 4, 2018, 8:14 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 | « no previous file | test/synchronizer.js » ('j') | 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-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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return errorCallback("synchronize_invalid_data"); 153 return errorCallback("synchronize_invalid_data");
154 let minVersion = headerMatch[1]; 154 let minVersion = headerMatch[1];
155 155
156 let params = { 156 let params = {
157 redirect: null, 157 redirect: null,
158 homepage: null, 158 homepage: null,
159 title: null, 159 title: null,
160 version: null, 160 version: null,
161 expires: null 161 expires: null
162 }; 162 };
163 for (let i = 0; i < lines.length; i++) 163 for (let i = 1; i < lines.length; i++)
164 { 164 {
165 let match = /^\s*!\s*(\w+)\s*:\s*(.*)/.exec(lines[i]); 165 let match = /^\s*!\s*(?:(\w+)\s*:\s*(.*)|\S)/.exec(lines[i]);
Manish Jethani 2018/09/05 18:10:08 How about this one: `/^\s*!\s*([^\s:]*)\s*(:)?\s*(
Sebastian Noack 2018/09/06 00:56:03 Done. Not sure if it's any easier to read through.
Manish Jethani 2018/09/06 05:53:53 I stand corrected, I meant `match[2]` A couple of
Sebastian Noack 2018/09/06 14:31:36 This is just a stop gap, what is eventually consid
Manish Jethani 2018/09/10 07:24:49 Acknowledged.
166 if (match) 166 if (!match)
167 break;
168
169 if (match[1] != undefined)
Manish Jethani 2018/09/05 18:10:08 We never compare with `undefined` in core. `undefi
Sebastian Noack 2018/09/06 00:56:03 Actually, I cannot redefine undefined, neither thr
Manish Jethani 2018/09/06 05:53:53 You can just shadow `undefined` in the local scope
167 { 170 {
168 let keyword = match[1].toLowerCase(); 171 let keyword = match[1].toLowerCase();
169 let value = match[2]; 172 if (params.hasOwnProperty(keyword))
170 if (keyword in params)
171 { 173 {
172 params[keyword] = value; 174 params[keyword] = match[2];
173 lines.splice(i--, 1); 175 lines.splice(i--, 1);
174 } 176 }
175 } 177 }
176 } 178 }
177 179
178 if (params.redirect) 180 if (params.redirect)
179 return redirectCallback(params.redirect); 181 return redirectCallback(params.redirect);
180 182
181 // Handle redirects 183 // Handle redirects
182 let subscription = Subscription.fromURL(downloadable.redirectURL || 184 let subscription = Subscription.fromURL(downloadable.redirectURL ||
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 subscription.filters.map(f => f.text).join("\n"); 335 subscription.filters.map(f => f.text).join("\n");
334 redirectCallback("data:text/plain," + encodeURIComponent(data)); 336 redirectCallback("data:text/plain," + encodeURIComponent(data));
335 } 337 }
336 }, false); 338 }, false);
337 request.send(null); 339 request.send(null);
338 } 340 }
339 } 341 }
340 } 342 }
341 }; 343 };
342 Synchronizer.init(); 344 Synchronizer.init();
OLDNEW
« no previous file with comments | « no previous file | test/synchronizer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld