Skip to content

Commit

Permalink
Reduce max hash in raw strings to 255
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Feb 4, 2023
1 parent 36525a7 commit 7459593
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/parse.rs
Expand Up @@ -472,6 +472,10 @@ fn raw_string(input: Cursor) -> Result<Cursor, Reject> {
_ => return Err(Reject),
}
}
if n > 255 {
// https://github.com/rust-lang/rust/pull/95251
return Err(Reject);
}
while let Some((i, ch)) = chars.next() {
match ch {
'"' if input.rest[i + 1..].starts_with(&input.rest[..n]) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/test.rs
Expand Up @@ -133,7 +133,7 @@ fn literal_raw_string() {
// https://github.com/rust-lang/rust/pull/95251
raw_string_literal_with_hashes(256)
.parse::<TokenStream>()
.unwrap();
.unwrap_err();
}

#[test]
Expand Down

0 comments on commit 7459593

Please sign in to comment.