properly escape backslashes in quotes in variables

This commit is contained in:
ConnorSkees 2020-03-23 20:09:27 -04:00
parent 981bf27cb8
commit cd40ada653
2 changed files with 9 additions and 1 deletions

View File

@ -126,7 +126,10 @@ pub(crate) fn read_until_closing_quote<I: Iterator<Item = Token>>(
is_escaped = false;
continue;
}
TokenKind::Symbol(Symbol::BackSlash) if !is_escaped => is_escaped = true,
TokenKind::Symbol(Symbol::BackSlash) if !is_escaped => {
t.push(tok);
is_escaped = true
},
TokenKind::Symbol(Symbol::BackSlash) => {
is_escaped = false;
t.push(tok);

View File

@ -98,3 +98,8 @@ test!(
"a {\n $a: red\n}\n\nb {\n color: blue;\n}\n",
"b {\n color: blue;\n}\n"
);
test!(
properly_escapes_backslash,
"a {\n $a: unquote(\"\\\\0 \");\n color: $a;\n}\n",
"a {\n color: \\0 ;\n}\n"
);