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

Unified Diff: lib/synchronizer.js

Issue 29630576: Issue 5146 - Part 2: Process http response in C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Dec. 5, 2017, 9:19 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « compiled/subscription/DownloadableSubscription.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/synchronizer.js
===================================================================
--- a/lib/synchronizer.js
+++ b/lib/synchronizer.js
@@ -140,27 +140,24 @@
{
let subscription = Subscription.fromURL(downloadable.url);
FilterNotifier.triggerListeners("subscription.downloading", subscription);
},
_onDownloadSuccess(downloadable, responseText, errorCallback,
redirectCallback)
{
- let lines = responseText.split(/[\r\n]+/);
- let headerMatch = /\[Adblock(?:\s*Plus\s*([\d.]+)?)?\]/i.exec(lines[0]);
- if (!headerMatch)
- return errorCallback("synchronize_invalid_data");
- let minVersion = headerMatch[1];
-
let parser = DownloadableSubscription.parseDownload();
- // Process filters
- for (let line of lines)
- parser.process(line);
+ if (!parser.process(responseText))
+ {
+ let {error} = parser;
+ parser.delete();
+ return errorCallback(error);
+ }
if (!parser.verifyChecksum())
return errorCallback("synchronize_checksum_mismatch");
if (parser.redirect)
{
let {redirect} = parser;
parser.delete();
@@ -206,21 +203,16 @@
{
url = null;
}
if (url && (url.protocol == "http:" || url.protocol == "https:"))
subscription.homepage = url.href;
}
- if (minVersion)
- subscription.requiredVersion = minVersion;
- else
- delete subscription.requiredVersion;
-
let expirationInterval = DEFAULT_EXPIRATION_INTERVAL;
let expiration = parser.finalize(subscription);
if (expiration != 0)
expirationInterval = expiration;
let [
softExpiration,
hardExpiration
« no previous file with comments | « compiled/subscription/DownloadableSubscription.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld