From 9918693037dce8aa4bb6f08741b6812923486c18 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 19 Jun 2024 11:26:03 +0200 Subject: Merging upstream version 1.76.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/regex/tests/regression_fuzz.rs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'vendor/regex/tests/regression_fuzz.rs') diff --git a/vendor/regex/tests/regression_fuzz.rs b/vendor/regex/tests/regression_fuzz.rs index 5f49530a7..f90ad4cb2 100644 --- a/vendor/regex/tests/regression_fuzz.rs +++ b/vendor/regex/tests/regression_fuzz.rs @@ -2,6 +2,14 @@ // can take quite a long time. Some of them take long enough that it's not // practical to run them in debug mode. :-/ +use regex::Regex; + +macro_rules! regex { + ($pattern:expr) => { + regex::Regex::new($pattern).unwrap() + }; +} + // See: https://oss-fuzz.com/testcase-detail/5673225499181056 // // Ignored by default since it takes too long in debug mode (almost a minute). @@ -14,8 +22,9 @@ fn fuzz1() { // See: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26505 // See: https://github.com/rust-lang/regex/issues/722 #[test] +#[cfg(feature = "unicode")] fn empty_any_errors_no_panic() { - assert!(regex_new!(r"\P{any}").is_err()); + assert!(Regex::new(r"\P{any}").is_ok()); } // This tests that a very large regex errors during compilation instead of @@ -27,7 +36,7 @@ fn empty_any_errors_no_panic() { #[test] fn big_regex_fails_to_compile() { let pat = "[\u{0}\u{e}\u{2}\\w~~>[l\t\u{0}]p?<]{971158}"; - assert!(regex_new!(pat).is_err()); + assert!(Regex::new(pat).is_err()); } // This was caught while on master but before a release went out(!). @@ -36,5 +45,17 @@ fn big_regex_fails_to_compile() { #[test] fn todo() { let pat = "(?:z|xx)@|xx"; - assert!(regex_new!(pat).is_ok()); + assert!(Regex::new(pat).is_ok()); +} + +// This was caused by the fuzzer, and then minimized by hand. +// +// This was caused by a bug in DFA determinization that mishandled NFA fail +// states. +#[test] +fn fail_branch_prevents_match() { + let pat = r".*[a&&b]A|B"; + let hay = "B"; + let re = Regex::new(pat).unwrap(); + assert!(re.is_match(hay)); } -- cgit v1.2.3