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

Unified Diff: lib/snippets.js

Issue 29852568: Issue 6811 - Parse blank arguments to snippets correctly (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Aug. 10, 2018, 3:25 p.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 | « no previous file | test/snippets.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/snippets.js
===================================================================
--- a/lib/snippets.js
+++ b/lib/snippets.js
@@ -89,21 +89,26 @@
{
let tree = [];
let escape = false;
let withinQuotes = false;
let unicodeEscape = null;
+ let quotesClosed = false;
+
let call = [];
let argument = "";
for (let character of script.trim() + ";")
{
+ let afterQuotesClosed = quotesClosed;
+ quotesClosed = false;
+
if (unicodeEscape != null)
{
unicodeEscape += character;
if (unicodeEscape.length == 4)
{
let codePoint = parseInt(unicodeEscape, 16);
if (!isNaN(codePoint))
@@ -123,24 +128,27 @@
}
else if (character == "\\")
{
escape = true;
}
else if (character == "'")
{
withinQuotes = !withinQuotes;
+
+ if (!withinQuotes)
+ quotesClosed = true;
}
else if (withinQuotes || character != ";" && !/\s/.test(character))
{
argument += character;
}
else
{
- if (argument)
+ if (argument || afterQuotesClosed)
{
call.push(argument);
argument = "";
}
if (character == ";" && call.length > 0)
{
tree.push(call);
« no previous file with comments | « no previous file | test/snippets.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld