Skip to content

Commit

Permalink
stricter parsing of string_continue escapes
Browse files Browse the repository at this point in the history
  • Loading branch information
ModProg authored and dtolnay committed Feb 23, 2023
1 parent 4168f6b commit 62d0aed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/test_lit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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", "...");
Expand Down

0 comments on commit 62d0aed

Please sign in to comment.