From cd40ada653f5c4cdcbb53bc491ec0eec0d6f42a4 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Mon, 23 Mar 2020 20:09:27 -0400 Subject: [PATCH] properly escape backslashes in quotes in variables --- src/utils.rs | 5 ++++- tests/variables.rs | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/utils.rs b/src/utils.rs index 5708e1e..07ef4f3 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -126,7 +126,10 @@ pub(crate) fn read_until_closing_quote>( 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); diff --git a/tests/variables.rs b/tests/variables.rs index dededf0..9c42149 100644 --- a/tests/variables.rs +++ b/tests/variables.rs @@ -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" +);