From 526b4aa15f8f5529d38ba526a51ac0f578d8f83e Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Tue, 31 Mar 2020 11:52:28 -0400 Subject: [PATCH] hexchars escaped in strings don't recieve trailing space --- src/utils.rs | 2 +- tests/str-escape.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils.rs b/src/utils.rs index dae27bd..d97e0b4 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -596,7 +596,7 @@ pub(crate) fn parse_quoted_string>( } let c = std::char::from_u32(u32::from_str_radix(&n, 16).unwrap()).unwrap(); if c.is_control() && c != '\t' && c != '\0' { - s.push_str(&format!("\\{} ", n.to_ascii_lowercase())); + s.push_str(&format!("\\{}", n.to_ascii_lowercase())); } else { s.push(c); } diff --git a/tests/str-escape.rs b/tests/str-escape.rs index 9aa497a..eb88004 100644 --- a/tests/str-escape.rs +++ b/tests/str-escape.rs @@ -106,3 +106,8 @@ test!( "a {\n color: \"\\g\";\n}\n", "a {\n color: \"g\";\n}\n" ); +test!( + escapes_hex_in_string_no_trailing_space, + "a {\n color: \"\\b\\c\\d\\e\\f\\g\\h\\i\\j\\k\\l\\m\\n\\o\\p\\q\\r\\s\\t\\u\\v\\w\\x\\y\\z\";\n}\n", + "a {\n color: \"\\b\\c\\d\\e\\fghijklmnopqrstuvwxyz\";\n}\n" +);