diff --git a/filtrex.js b/filtrex.js index 103d97a..36bc2fb 100644 --- a/filtrex.js +++ b/filtrex.js @@ -122,12 +122,7 @@ function filtrexParser() { return "SYMBOL";` ], // 'some-symbol' - ['"(?:[^"])*"', - `yytext = JSON.stringify( - yytext.substr(1, yyleng-2) - ); - return "STRING";` - ], // "foo" + ['"(?:\\\\"|[^"])*"', 'return "STRING";'], // "foo" // End ['$', 'return "EOF";'], diff --git a/src/filtrex.js b/src/filtrex.js index 1eb010a..9e31423 100644 --- a/src/filtrex.js +++ b/src/filtrex.js @@ -122,12 +122,7 @@ function filtrexParser() { return "SYMBOL";` ], // 'some-symbol' - ['"(?:[^"])*"', - `yytext = JSON.stringify( - yytext.substr(1, yyleng-2) - ); - return "STRING";` - ], // "foo" + ['"(?:\\\\"|[^"])*"', 'return "STRING";'], // "foo" // End ['$', 'return "EOF";'], diff --git a/test/filtrex-test.html b/test/filtrex-test.html index 8bc6a56..ea5c4e0 100644 --- a/test/filtrex-test.html +++ b/test/filtrex-test.html @@ -173,9 +173,14 @@ }, 'backslash escaping': function() { - eq('\\good', compileExpression(`"\\" + '\\'`)({'\\':'good'})); + eq('\\good', compileExpression(`"\\\\" + '\\'`)({'\\':'good'})); + eq('\\good', compileExpression(`"\\\\" + '\\\\'`)({'\\\\':'good'})); }, + 'double quotes inside strings': function() { + eq('"test"', compileExpression('"\\"test\\""')({})); + } + });