Commit ee3158dc authored by Sebastian Noack's avatar Sebastian Noack

Issue 6923 - Simplify parsing of metadata

parent 25519781
......@@ -160,18 +160,15 @@ class Synchronizer
};
for (let i = 1; i < lines.length; i++)
{
let match = /^\s*!\s*(?:(\w+)\s*:\s*(.*)|\S)/.exec(lines[i]);
let match = /^\s*!\s*(.*?)\s*:\s*(.*)/.exec(lines[i]);
if (!match)
break;
if (typeof match[1] != "undefined")
let keyword = match[1].toLowerCase();
if (params.hasOwnProperty(keyword))
{
let keyword = match[1].toLowerCase();
if (params.hasOwnProperty(keyword))
{
params[keyword] = match[2];
lines.splice(i--, 1);
}
params[keyword] = match[2];
lines.splice(i--, 1);
}
}
......
......@@ -259,7 +259,7 @@ for (let currentTest of [
this.registerHandler("/subscription", metadata =>
{
requests.push(this.getTimeOffset());
return [Cr.NS_OK, 200, "[Adblock]\n!foo\n!Expires: " + currentTest.expiration + "\nbar"];
return [Cr.NS_OK, 200, "[Adblock]\n!Expires: " + currentTest.expiration + "\nbar"];
});
this.randomResult = currentTest.randomResult;
......@@ -319,7 +319,7 @@ exports.testRedirects = function(test)
this.registerHandler("/subscription", metadata =>
{
return [Cr.NS_OK, 200, "[Adblock]\n!foo\n!Redirect: http://example.com/redirected\nbar"];
return [Cr.NS_OK, 200, "[Adblock]\n!Redirect: http://example.com/redirected\nbar"];
});
let requests;
......@@ -335,7 +335,7 @@ exports.testRedirects = function(test)
this.registerHandler("/redirected", metadata =>
{
requests.push(this.getTimeOffset());
return [Cr.NS_OK, 200, "[Adblock]\n!foo\n! Expires: 8 hours\nbar"];
return [Cr.NS_OK, 200, "[Adblock]\n! Expires: 8 hours\nbar"];
});
resetSubscription(subscription);
......@@ -347,7 +347,7 @@ exports.testRedirects = function(test)
this.registerHandler("/redirected", metadata =>
{
return [Cr.NS_OK, 200, "[Adblock]\n!foo\n!Redirect: http://example.com/subscription\nbar"];
return [Cr.NS_OK, 200, "[Adblock]\n!Redirect: http://example.com/subscription\nbar"];
});
subscription = Subscription.fromURL("http://example.com/subscription");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment