1
0

Correctly handle semicolons within search term values

This commit is contained in:
Daniel Spofford
2015-05-04 09:54:17 -05:00
parent 5090897e18
commit 5a37692e67

View File

@@ -30,10 +30,11 @@ exports.parse = function (string, options) {
// Get a list of search terms respecting single and double quotes
var terms = string.match(/(\S+:'(?:[^'\\]|\\.)*')|(\S+:"(?:[^"\\]|\\.)*")|\S+|\S+:\S+/g);
for (var i = 0; i < terms.length; i++) {
if(terms[i].indexOf(':') !== -1) {
var sepIndex = terms[i].indexOf(':');
if(sepIndex !== -1) {
var split = terms[i].split(':'),
key = split[0],
val = split[1];
key = terms[i].slice(0, sepIndex),
val = terms[i].slice(sepIndex + 1);
// Strip surrounding quotes
val = val.replace(/^\"|\"$|^\'|\'$/g, '');
// Strip backslashes respecting escapes