Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/filepatterns.rs @ 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 |
comparison
equal
deleted
inserted
replaced
44832:ad1ec40975aa | 44833:1e9bfeaec9ba |
---|---|
179 PatternSyntax::Regexp => pattern.to_owned(), | 179 PatternSyntax::Regexp => pattern.to_owned(), |
180 PatternSyntax::RelRegexp => { | 180 PatternSyntax::RelRegexp => { |
181 // The `regex` crate accepts `**` while `re2` and Python's `re` | 181 // The `regex` crate accepts `**` while `re2` and Python's `re` |
182 // do not. Checking for `*` correctly triggers the same error all | 182 // do not. Checking for `*` correctly triggers the same error all |
183 // engines. | 183 // engines. |
184 if pattern[0] == b'^' || pattern[0] == b'*' { | 184 if pattern[0] == b'^' |
185 || pattern[0] == b'*' | |
186 || pattern.starts_with(b".*") | |
187 { | |
185 return pattern.to_owned(); | 188 return pattern.to_owned(); |
186 } | 189 } |
187 [&b".*"[..], pattern].concat() | 190 [&b".*"[..], pattern].concat() |
188 } | 191 } |
189 PatternSyntax::Path | PatternSyntax::RelPath => { | 192 PatternSyntax::Path | PatternSyntax::RelPath => { |