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

Side by Side Diff: lib/synchronizer.js

Issue 29807560: Issue 6745 - Prefer strict equality operator (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created June 14, 2018, 4:11 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 | « lib/subscriptionClasses.js ('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-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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 /** 108 /**
109 * Creates a Downloadable instance for a subscription. 109 * Creates a Downloadable instance for a subscription.
110 * @param {Subscription} subscription 110 * @param {Subscription} subscription
111 * @param {boolean} manual 111 * @param {boolean} manual
112 * @return {Downloadable} 112 * @return {Downloadable}
113 */ 113 */
114 _getDownloadable(subscription, manual) 114 _getDownloadable(subscription, manual)
115 { 115 {
116 let result = new Downloadable(subscription.url); 116 let result = new Downloadable(subscription.url);
117 if (subscription.lastDownload != subscription.lastSuccess) 117 if (subscription.lastDownload !== subscription.lastSuccess)
118 result.lastError = subscription.lastDownload * MILLIS_IN_SECOND; 118 result.lastError = subscription.lastDownload * MILLIS_IN_SECOND;
119 result.lastCheck = subscription.lastCheck * MILLIS_IN_SECOND; 119 result.lastCheck = subscription.lastCheck * MILLIS_IN_SECOND;
120 result.lastVersion = subscription.version; 120 result.lastVersion = subscription.version;
121 result.softExpiration = subscription.softExpiration * MILLIS_IN_SECOND; 121 result.softExpiration = subscription.softExpiration * MILLIS_IN_SECOND;
122 result.hardExpiration = subscription.expires * MILLIS_IN_SECOND; 122 result.hardExpiration = subscription.expires * MILLIS_IN_SECOND;
123 result.manual = manual; 123 result.manual = manual;
124 result.downloadCount = subscription.downloadCount; 124 result.downloadCount = subscription.downloadCount;
125 return result; 125 return result;
126 }, 126 },
127 127
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 let match = /^\s*!\s*(\w+)\s*:\s*(.*)/.exec(lines[i]); 169 let match = /^\s*!\s*(\w+)\s*:\s*(.*)/.exec(lines[i]);
170 if (match) 170 if (match)
171 { 171 {
172 let keyword = match[1].toLowerCase(); 172 let keyword = match[1].toLowerCase();
173 let value = match[2]; 173 let value = match[2];
174 if (keyword in params) 174 if (keyword in params)
175 { 175 {
176 params[keyword] = value; 176 params[keyword] = value;
177 remove.push(i); 177 remove.push(i);
178 } 178 }
179 else if (keyword == "checksum") 179 else if (keyword === "checksum")
180 { 180 {
181 lines.splice(i--, 1); 181 lines.splice(i--, 1);
182 let checksum = Utils.generateChecksum(lines); 182 let checksum = Utils.generateChecksum(lines);
183 if (checksum && checksum != value.replace(/=+$/, "")) 183 if (checksum && checksum !== value.replace(/=+$/, ""))
184 return errorCallback("synchronize_checksum_mismatch"); 184 return errorCallback("synchronize_checksum_mismatch");
185 } 185 }
186 } 186 }
187 } 187 }
188 188
189 if (params.redirect) 189 if (params.redirect)
190 return redirectCallback(params.redirect); 190 return redirectCallback(params.redirect);
191 191
192 // Handle redirects 192 // Handle redirects
193 let subscription = Subscription.fromURL(downloadable.redirectURL || 193 let subscription = Subscription.fromURL(downloadable.redirectURL ||
194 downloadable.url); 194 downloadable.url);
195 if (downloadable.redirectURL && 195 if (downloadable.redirectURL &&
196 downloadable.redirectURL != downloadable.url) 196 downloadable.redirectURL !== downloadable.url)
197 { 197 {
198 let oldSubscription = Subscription.fromURL(downloadable.url); 198 let oldSubscription = Subscription.fromURL(downloadable.url);
199 subscription.title = oldSubscription.title; 199 subscription.title = oldSubscription.title;
200 subscription.disabled = oldSubscription.disabled; 200 subscription.disabled = oldSubscription.disabled;
201 subscription.lastCheck = oldSubscription.lastCheck; 201 subscription.lastCheck = oldSubscription.lastCheck;
202 202
203 let listed = FilterStorage.knownSubscriptions.has(oldSubscription.url); 203 let listed = FilterStorage.knownSubscriptions.has(oldSubscription.url);
204 if (listed) 204 if (listed)
205 FilterStorage.removeSubscription(oldSubscription); 205 FilterStorage.removeSubscription(oldSubscription);
206 206
(...skipping 21 matching lines...) Expand all
228 let url; 228 let url;
229 try 229 try
230 { 230 {
231 url = new URL(params.homepage); 231 url = new URL(params.homepage);
232 } 232 }
233 catch (e) 233 catch (e)
234 { 234 {
235 url = null; 235 url = null;
236 } 236 }
237 237
238 if (url && (url.protocol == "http:" || url.protocol == "https:")) 238 if (url && (url.protocol === "http:" || url.protocol === "https:"))
239 subscription.homepage = url.href; 239 subscription.homepage = url.href;
240 } 240 }
241 241
242 if (params.title) 242 if (params.title)
243 { 243 {
244 subscription.title = params.title; 244 subscription.title = params.title;
245 subscription.fixedTitle = true; 245 subscription.fixedTitle = true;
246 } 246 }
247 else 247 else
248 subscription.fixedTitle = false; 248 subscription.fixedTitle = false;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 request.channel.VALIDATE_ALWAYS; 330 request.channel.VALIDATE_ALWAYS;
331 request.addEventListener("load", ev => 331 request.addEventListener("load", ev =>
332 { 332 {
333 if (onShutdown.done) 333 if (onShutdown.done)
334 return; 334 return;
335 335
336 if (!FilterStorage.knownSubscriptions.has(subscription.url)) 336 if (!FilterStorage.knownSubscriptions.has(subscription.url))
337 return; 337 return;
338 338
339 let match = /^(\d+)(?:\s+(\S+))?$/.exec(request.responseText); 339 let match = /^(\d+)(?:\s+(\S+))?$/.exec(request.responseText);
340 if (match && match[1] == "301" && // Moved permanently 340 if (match && match[1] === "301" && // Moved permanently
341 match[2] && /^https?:\/\//i.test(match[2])) 341 match[2] && /^https?:\/\//i.test(match[2]))
342 { 342 {
343 redirectCallback(match[2]); 343 redirectCallback(match[2]);
344 } 344 }
345 else if (match && match[1] == "410") // Gone 345 else if (match && match[1] === "410") // Gone
346 { 346 {
347 let data = "[Adblock]\n" + 347 let data = "[Adblock]\n" +
348 subscription.filters.map(f => f.text).join("\n"); 348 subscription.filters.map(f => f.text).join("\n");
349 redirectCallback("data:text/plain," + encodeURIComponent(data)); 349 redirectCallback("data:text/plain," + encodeURIComponent(data));
350 } 350 }
351 }, false); 351 }, false);
352 request.send(null); 352 request.send(null);
353 } 353 }
354 } 354 }
355 } 355 }
356 }; 356 };
357 Synchronizer.init(); 357 Synchronizer.init();
OLDNEW
« no previous file with comments | « lib/subscriptionClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld