From 2db3398fe29177cb7ff66733bbcb189ecd741531 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sat, 16 May 2020 17:20:53 -0400 Subject: [PATCH] properly handle escaped newlines in quoted strings --- src/utils/strings.rs | 3 ++- tests/str-escape.rs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils/strings.rs b/src/utils/strings.rs index fae92c6..dd38649 100644 --- a/src/utils/strings.rs +++ b/src/utils/strings.rs @@ -302,7 +302,8 @@ pub(crate) fn parse_quoted_string>( }; if first.kind == '\n' { - return Err(("Expected escape sequence.", first.pos()).into()); + toks.next(); + continue; } if first.kind.is_ascii_hexdigit() { diff --git a/tests/str-escape.rs b/tests/str-escape.rs index c0ba921..323bb78 100644 --- a/tests/str-escape.rs +++ b/tests/str-escape.rs @@ -172,3 +172,8 @@ error!( escape_sequence_does_not_fit_inside_char, "a {\n color: \\110000;\n}\n", "Error: Invalid escape sequence." ); +test!( + escaped_newline_in_quoted_string, + "a {\n color: \"foo\\\nbar\";\n}\n", + "a {\n color: \"foobar\";\n}\n" +);