diff options
author | Joel Galenson <jgalenson@google.com> | 2021-06-09 19:58:02 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-06-09 19:58:02 +0000 |
commit | df6134fce73f346b7e92e4b167d0b96514cdbad5 (patch) | |
tree | 02c0b3035a3cf71f10f04c344fb3e636a1090409 /tests | |
parent | b6bd22e71f7fc5ace8beb388f0af7dcc82f81798 (diff) | |
parent | 8634f7155049fae897b81d2ce314e54993fd68e6 (diff) | |
download | regex-df6134fce73f346b7e92e4b167d0b96514cdbad5.tar.gz |
Upgrade rust/crates/regex to 1.5.4 am: 3874808a33 am: 8634f71550
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/regex/+/1713148
Change-Id: I857ffdca7460140229219dae8030bf4c6bff8858
Diffstat (limited to 'tests')
-rw-r--r-- | tests/regression_fuzz.rs | 12 | ||||
-rw-r--r-- | tests/replace.rs | 4 | ||||
-rw-r--r-- | tests/test_backtrack.rs | 3 | ||||
-rw-r--r-- | tests/test_backtrack_bytes.rs | 3 | ||||
-rw-r--r-- | tests/test_backtrack_utf8bytes.rs | 3 | ||||
-rw-r--r-- | tests/test_crates_regex.rs | 3 | ||||
-rw-r--r-- | tests/test_default.rs | 3 | ||||
-rw-r--r-- | tests/test_default_bytes.rs | 3 | ||||
-rw-r--r-- | tests/test_nfa.rs | 3 | ||||
-rw-r--r-- | tests/test_nfa_bytes.rs | 3 | ||||
-rw-r--r-- | tests/test_nfa_utf8bytes.rs | 3 |
11 files changed, 15 insertions, 28 deletions
diff --git a/tests/regression_fuzz.rs b/tests/regression_fuzz.rs index 5f92ed0..4e76704 100644 --- a/tests/regression_fuzz.rs +++ b/tests/regression_fuzz.rs @@ -17,3 +17,15 @@ fn fuzz1() { fn empty_any_errors_no_panic() { assert!(regex_new!(r"\P{any}").is_err()); } + +// This tests that a very large regex errors during compilation instead of +// using gratuitous amounts of memory. The specific problem is that the +// compiler wasn't accounting for the memory used by Unicode character classes +// correctly. +// +// See: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33579 +#[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()); +} diff --git a/tests/replace.rs b/tests/replace.rs index 700aff2..1dc6106 100644 --- a/tests/replace.rs +++ b/tests/replace.rs @@ -94,7 +94,7 @@ replace!( replace, r"([0-9]+)", "age: 26", - |captures: &Captures| { + |captures: &Captures<'_>| { match_text!(captures.get(1).unwrap())[0..1].to_owned() }, "age: 2" @@ -104,7 +104,7 @@ replace!( replace, r"[0-9]+", "age: 26", - |_captures: &Captures| t!("Z").to_owned(), + |_captures: &Captures<'_>| t!("Z").to_owned(), "age: Z" ); diff --git a/tests/test_backtrack.rs b/tests/test_backtrack.rs index 617185f..fb934e2 100644 --- a/tests/test_backtrack.rs +++ b/tests/test_backtrack.rs @@ -1,8 +1,5 @@ #![cfg_attr(feature = "pattern", feature(pattern))] -extern crate rand; -extern crate regex; - macro_rules! regex_new { ($re:expr) => {{ use regex::internal::ExecBuilder; diff --git a/tests/test_backtrack_bytes.rs b/tests/test_backtrack_bytes.rs index 17df4d8..a59426c 100644 --- a/tests/test_backtrack_bytes.rs +++ b/tests/test_backtrack_bytes.rs @@ -1,6 +1,3 @@ -extern crate rand; -extern crate regex; - macro_rules! regex_new { ($re:expr) => {{ use regex::internal::ExecBuilder; diff --git a/tests/test_backtrack_utf8bytes.rs b/tests/test_backtrack_utf8bytes.rs index 78a0135..6d308e9 100644 --- a/tests/test_backtrack_utf8bytes.rs +++ b/tests/test_backtrack_utf8bytes.rs @@ -1,8 +1,5 @@ #![cfg_attr(feature = "pattern", feature(pattern))] -extern crate rand; -extern crate regex; - macro_rules! regex_new { ($re:expr) => {{ use regex::internal::ExecBuilder; diff --git a/tests/test_crates_regex.rs b/tests/test_crates_regex.rs index d697683..a681604 100644 --- a/tests/test_crates_regex.rs +++ b/tests/test_crates_regex.rs @@ -1,6 +1,3 @@ -extern crate quickcheck; -extern crate regex; - /* * This test is a minimal version of <rofl_0> and <subdiff_0> * diff --git a/tests/test_default.rs b/tests/test_default.rs index af634a0..d4365fb 100644 --- a/tests/test_default.rs +++ b/tests/test_default.rs @@ -1,7 +1,6 @@ #![cfg_attr(feature = "pattern", feature(pattern))] -extern crate rand; -extern crate regex; +use regex; // Due to macro scoping rules, this definition only applies for the modules // defined below. Effectively, it allows us to use the same tests for both diff --git a/tests/test_default_bytes.rs b/tests/test_default_bytes.rs index e4a25dc..f200596 100644 --- a/tests/test_default_bytes.rs +++ b/tests/test_default_bytes.rs @@ -1,6 +1,3 @@ -extern crate rand; -extern crate regex; - macro_rules! regex_new { ($re:expr) => {{ use regex::bytes::Regex; diff --git a/tests/test_nfa.rs b/tests/test_nfa.rs index 05dad23..e5a67d1 100644 --- a/tests/test_nfa.rs +++ b/tests/test_nfa.rs @@ -1,8 +1,5 @@ #![cfg_attr(feature = "pattern", feature(pattern))] -extern crate rand; -extern crate regex; - macro_rules! regex_new { ($re:expr) => {{ use regex::internal::ExecBuilder; diff --git a/tests/test_nfa_bytes.rs b/tests/test_nfa_bytes.rs index 1042318..0a10e03 100644 --- a/tests/test_nfa_bytes.rs +++ b/tests/test_nfa_bytes.rs @@ -1,6 +1,3 @@ -extern crate rand; -extern crate regex; - macro_rules! regex_new { ($re:expr) => {{ use regex::internal::ExecBuilder; diff --git a/tests/test_nfa_utf8bytes.rs b/tests/test_nfa_utf8bytes.rs index 86487a1..36a572b 100644 --- a/tests/test_nfa_utf8bytes.rs +++ b/tests/test_nfa_utf8bytes.rs @@ -1,8 +1,5 @@ #![cfg_attr(feature = "pattern", feature(pattern))] -extern crate rand; -extern crate regex; - macro_rules! regex_new { ($re:expr) => {{ use regex::internal::ExecBuilder; |