properly escape backslashes

This commit is contained in:
ConnorSkees 2020-02-24 19:13:28 -05:00
parent c4d365a124
commit 6c5cf4b405
2 changed files with 10 additions and 1 deletions

View File

@ -189,7 +189,11 @@ pub(crate) fn parse_quoted_string<I: Iterator<Item = Token>>(
continue;
}
TokenKind::Symbol(Symbol::BackSlash) if !is_escaped => is_escaped = true,
TokenKind::Symbol(Symbol::BackSlash) => s.push('\\'),
TokenKind::Symbol(Symbol::BackSlash) => {
is_escaped = false;
s.push('\\');
continue;
},
TokenKind::Interpolation if !is_escaped => {
found_interpolation = true;
s.push_str(

View File

@ -350,3 +350,8 @@ test!(
"a {\n color: \"f\"foo;\n}\n",
"a {\n color: \"f\" foo;\n}\n"
);
test!(
escaped_backslash,
"a {\n color: \"\\\\\";\n}\n",
"a {\n color: \"\\\";\n}\n"
);