| Left: | ||
| Right: |
| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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*(\S.*?)\s*:\s*(.*)/.exec(lines[i]); |
|
Sebastian Noack
2018/09/03 18:47:13
You might wonder why I changed this regular expres
Manish Jethani
2018/09/04 07:14:41
Acknowledged.
Sebastian Noack
2018/09/04 15:32:38
You have a point there. But in this regard, IMO we
| |
| 166 if (match) | 166 if (!match) |
| 167 break; | |
| 168 | |
| 169 let keyword = match[1].toLowerCase(); | |
| 170 if (keyword in params) | |
|
Manish Jethani
2018/09/04 07:14:41
BTW I find in my tests that `params.hasOwnProperty
Sebastian Noack
2018/09/04 14:22:06
IMO the in-operator reads much nicer, and this isn
Manish Jethani
2018/09/04 15:01:45
Acknowledged.
(Aside from performance, it's also
| |
| 167 { | 171 { |
| 168 let keyword = match[1].toLowerCase(); | 172 params[keyword] = match[2]; |
| 169 let value = match[2]; | 173 lines.splice(i--, 1); |
|
Manish Jethani
2018/09/04 07:14:41
Since we're considering malformed keywords as well
Sebastian Noack
2018/09/04 14:22:06
Historically, if it's not recognized as supported
Manish Jethani
2018/09/04 15:01:45
OK, fair enough. I'd like to consider not using `s
| |
| 170 if (keyword in params) | |
| 171 { | |
| 172 params[keyword] = value; | |
| 173 lines.splice(i--, 1); | |
| 174 } | |
| 175 } | 174 } |
| 176 } | 175 } |
| 177 | 176 |
| 178 if (params.redirect) | 177 if (params.redirect) |
| 179 return redirectCallback(params.redirect); | 178 return redirectCallback(params.redirect); |
| 180 | 179 |
| 181 // Handle redirects | 180 // Handle redirects |
| 182 let subscription = Subscription.fromURL(downloadable.redirectURL || | 181 let subscription = Subscription.fromURL(downloadable.redirectURL || |
| 183 downloadable.url); | 182 downloadable.url); |
| 184 if (downloadable.redirectURL && | 183 if (downloadable.redirectURL && |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 subscription.filters.map(f => f.text).join("\n"); | 332 subscription.filters.map(f => f.text).join("\n"); |
| 334 redirectCallback("data:text/plain," + encodeURIComponent(data)); | 333 redirectCallback("data:text/plain," + encodeURIComponent(data)); |
| 335 } | 334 } |
| 336 }, false); | 335 }, false); |
| 337 request.send(null); | 336 request.send(null); |
| 338 } | 337 } |
| 339 } | 338 } |
| 340 } | 339 } |
| 341 }; | 340 }; |
| 342 Synchronizer.init(); | 341 Synchronizer.init(); |
| OLD | NEW |