mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 16:07:35 +00:00
Shell: Correctly handle escaped quote characters in strings
Previously "foo\`bar" was treated literally, but \` is a valid escape character. This commit makes that string correctly evaluate as "foo`bar".
This commit is contained in:
parent
bbfedf17b7
commit
aecd91aedc
1 changed files with 4 additions and 0 deletions
|
@ -1685,6 +1685,10 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_word()
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '\\':
|
case '\\':
|
||||||
if (!escape && i + 1 < string.length()) {
|
if (!escape && i + 1 < string.length()) {
|
||||||
|
if (run_start.has_value())
|
||||||
|
TRY(append_string_literal(string.substring_view(*run_start, i - *run_start)));
|
||||||
|
run_start = i + 1;
|
||||||
|
|
||||||
if (is_one_of(string[i + 1], '"', '\'', '$', '`', '\\')) {
|
if (is_one_of(string[i + 1], '"', '\'', '$', '`', '\\')) {
|
||||||
escape = in_quote != Quote::Single;
|
escape = in_quote != Quote::Single;
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue