# HG changeset patch # User Raphaël Gomès # Date 2020-05-07 21:53:12 # Node ID 1e9bfeaec9ba555c9e2c9bbd6e33db48f9e1fa9a # Parent ad1ec40975aa8032c573c5bb021cca0af4c7dea8 rust-regex: prevent nonsensical `.*.*` pattern from happening Differential Revision: https://phab.mercurial-scm.org/D8507 diff --git a/rust/hg-core/src/filepatterns.rs b/rust/hg-core/src/filepatterns.rs --- a/rust/hg-core/src/filepatterns.rs +++ b/rust/hg-core/src/filepatterns.rs @@ -181,7 +181,10 @@ fn _build_single_regex(entry: &IgnorePat // The `regex` crate accepts `**` while `re2` and Python's `re` // do not. Checking for `*` correctly triggers the same error all // engines. - if pattern[0] == b'^' || pattern[0] == b'*' { + if pattern[0] == b'^' + || pattern[0] == b'*' + || pattern.starts_with(b".*") + { return pattern.to_owned(); } [&b".*"[..], pattern].concat()