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 f0a3490 commit dffd53c
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,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 dffd53c

Please sign in to comment.