Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion regex-automata/src/meta/wrappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ impl BoundedBacktracker {
}
// If the backtracker is just going to return an error because the
// haystack is too long, then obviously do not use it.
if input.get_span().len() > engine.max_haystack_len() {
let max_haystack_len = engine.max_haystack_len();
if max_haystack_len == 0 || input.get_span().len() > max_haystack_len {
return None;
}
Some(engine)
Expand Down
8 changes: 8 additions & 0 deletions regex-automata/tests/meta/suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ fn default() -> Result<()> {
Ok(())
}

#[test]
fn backtracker_zero_max_haystack_len() -> Result<()> {
let config = Regex::config().nfa_size_limit(Some(1_000_000_000));
let re = Regex::builder().configure(config).build(r"^.{0,404600}$")?;
assert!(re.is_match(""));
Ok(())
}

/// Tests the default configuration minus the full DFA.
#[test]
fn no_dfa() -> Result<()> {
Expand Down