From 62d0aeda487a835a3a28d5efeb24b92c68ab3834 Mon Sep 17 00:00:00 2001 From: Roland Fredenhagen Date: Mon, 20 Feb 2023 17:51:43 +0100 Subject: [PATCH] stricter parsing of string_continue escapes --- src/lit.rs | 6 +++--- tests/test_lit.rs | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lit.rs b/src/lit.rs index 130b40ed1f..e002ce71ac 100644 --- a/src/lit.rs +++ b/src/lit.rs @@ -1117,9 +1117,9 @@ mod value { b'\'' => '\'', b'"' => '"', b'\r' | b'\n' => loop { - let ch = next_chr(s); - if ch.is_whitespace() { - s = &s[ch.len_utf8()..]; + let b = byte(s, 0); + if matches!(b, b' ' | b'\t' | b'\n' | b'\r') { + s = &s[1..]; } else { continue 'outer; } diff --git a/tests/test_lit.rs b/tests/test_lit.rs index ebe077c617..46d6f634c2 100644 --- a/tests/test_lit.rs +++ b/tests/test_lit.rs @@ -50,6 +50,10 @@ fn strings() { "\"contains\nnewlines\\\nescaped newlines\"", "contains\nnewlinesescaped newlines", ); + test_string( + "\"escaped newline\\\n \x0C unsupported whitespace\"", + "escaped newline\x0C unsupported whitespace", + ); test_string("r\"raw\nstring\\\nhere\"", "raw\nstring\\\nhere"); test_string("\"...\"q", "..."); test_string("r\"...\"q", "...");