From 4fb4e2960d4f8a6cb6637255a026f80a58e9efcd Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 18 Oct 2018 15:28:46 -0700 Subject: [PATCH] Fix handling of escaped chars in strings --- corpus/literals.txt | 13 +++++++++++++ grammar.js | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/corpus/literals.txt b/corpus/literals.txt index 37fdc53..7827371 100644 --- a/corpus/literals.txt +++ b/corpus/literals.txt @@ -306,3 +306,16 @@ a+=(foo "bar" $(baz)) (word) (string) (command_substitution (command (command_name (word))))))) + +============================== +Escaped characters in strings +============================== + +echo -ne "\033k$1\033\\" > /dev/stderr + +--- + +(program + (redirected_statement + (command (command_name (word)) (word) (string (simple_expansion (variable_name)))) + (file_redirect (word)))) diff --git a/grammar.js b/grammar.js index d8825d1..6b47c1a 100644 --- a/grammar.js +++ b/grammar.js @@ -425,7 +425,7 @@ module.exports = grammar({ '"' ), - _string_content: $ => token(prec(-1, /([^"`$]|\\.)+/)), + _string_content: $ => token(prec(-1, /([^"`$\\]|\\(.|\n))+/)), array: $ => seq( '(',