Commit ddc42a61 authored by Clement Ho's avatar Clement Ho

Fix bug where token values with 2 double quotes were not treated as a complete value

parent f0608878
...@@ -119,19 +119,26 @@ ...@@ -119,19 +119,26 @@
const keyMatch = validTokenKeys.filter(v => v.key === tokenKey)[0]; const keyMatch = validTokenKeys.filter(v => v.key === tokenKey)[0];
const symbolMatch = validTokenKeys.filter(v => v.symbol === tokenSymbol)[0]; const symbolMatch = validTokenKeys.filter(v => v.symbol === tokenSymbol)[0];
const doubleQuoteOccurrences = tokenValue.split('"').length - 1;
const singleQuoteOccurrences = tokenValue.split('\'').length - 1;
const doubleQuoteIndex = tokenValue.indexOf('"'); const doubleQuoteIndex = tokenValue.indexOf('"');
const singleQuoteIndex = tokenValue.indexOf('\''); const singleQuoteIndex = tokenValue.indexOf('\'');
const doubleQuoteExist = doubleQuoteIndex !== -1; const doubleQuoteExist = doubleQuoteIndex !== -1;
const singleQuoteExist = singleQuoteIndex !== -1; const singleQuoteExist = singleQuoteIndex !== -1;
if ((doubleQuoteExist && !singleQuoteExist) || const doubleQuoteExistOnly = doubleQuoteExist && !singleQuoteExist;
(doubleQuoteExist && singleQuoteExist && doubleQuoteIndex < singleQuoteIndex)) { const doubleQuoteIsBeforeSingleQuote = doubleQuoteExist && singleQuoteExist && doubleQuoteIndex < singleQuoteIndex;
const singleQuoteExistOnly = singleQuoteExist && !doubleQuoteExist;
const singleQuoteIsBeforeDoubleQuote = doubleQuoteExist && singleQuoteExist && singleQuoteIndex < doubleQuoteIndex;
if ((doubleQuoteExistOnly || doubleQuoteIsBeforeSingleQuote) && doubleQuoteOccurrences % 2 !== 0) {
// " is found and is in front of ' (if any) // " is found and is in front of ' (if any)
lastQuotation = '"'; lastQuotation = '"';
incompleteToken = true; incompleteToken = true;
} else if ((singleQuoteExist && !doubleQuoteExist) || } else if ((singleQuoteExistOnly || singleQuoteIsBeforeDoubleQuote) && singleQuoteOccurrences % 2 !== 0) {
(doubleQuoteExist && singleQuoteExist && singleQuoteIndex < doubleQuoteIndex)) {
// ' is found and is in front of " (if any) // ' is found and is in front of " (if any)
lastQuotation = '\''; lastQuotation = '\'';
incompleteToken = true; incompleteToken = true;
......
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