changeset 44833:1e9bfeaec9ba

rust-regex: prevent nonsensical `.*.*` pattern from happening Differential Revision: https://phab.mercurial-scm.org/D8507
author Raphaël Gomès <rgomes@octobus.net>
date Thu, 07 May 2020 23:53:12 +0200
parents ad1ec40975aa
children be6401a25726
files rust/hg-core/src/filepatterns.rs
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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()