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", "...");