From dffd53caa1ae33112be444c0e452ec4f8b046d56 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 4 Feb 2023 15:25:26 -0800 Subject: [PATCH] Reduce max hash in raw strings to 255 --- src/parse.rs | 4 ++++ tests/test.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/parse.rs b/src/parse.rs index 307e0650..2a87948a 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -472,6 +472,10 @@ fn raw_string(input: Cursor) -> Result { _ => 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]) => { diff --git a/tests/test.rs b/tests/test.rs index 0033418e..e0af1512 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -137,7 +137,7 @@ fn literal_raw_string() { // https://github.com/rust-lang/rust/pull/95251 raw_string_literal_with_hashes(256) .parse::() - .unwrap(); + .unwrap_err(); } #[test]