summaryrefslogtreecommitdiffstats
path: root/vendor/regex/tests/regression_fuzz.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/regex/tests/regression_fuzz.rs
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/regex/tests/regression_fuzz.rs')
-rw-r--r--vendor/regex/tests/regression_fuzz.rs27
1 files changed, 24 insertions, 3 deletions
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));
}