# HG changeset patch # User Raphaël Gomès # Date 1588888392 -7200 # Node ID 1e9bfeaec9ba555c9e2c9bbd6e33db48f9e1fa9a # Parent ad1ec40975aa8032c573c5bb021cca0af4c7dea8 rust-regex: prevent nonsensical `.*.*` pattern from happening Differential Revision: https://phab.mercurial-scm.org/D8507 diff -r ad1ec40975aa -r 1e9bfeaec9ba rust/hg-core/src/filepatterns.rs --- a/rust/hg-core/src/filepatterns.rs Thu May 07 23:52:08 2020 +0200 +++ b/rust/hg-core/src/filepatterns.rs Thu May 07 23:53:12 2020 +0200 @@ -181,7 +181,10 @@ // 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()