Mercurial > public > mercurial-scm > hg
changeset 52718:1c83ebf78f74 stable
narrow: stricter validation of narrowspec patterns
While we're at it, forbid empty path components (aka repeated slashes) as well
because they can cause problems (at the very least a crash failing HgPath
validation in rust code path).
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Fri, 10 Jan 2025 16:14:40 +0000 |
parents | a7669e7b0355 |
children | 77b95a4abbb2 |
files | mercurial/narrowspec.py tests/test-narrow.t |
diffstat | 2 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/narrowspec.py Fri Jan 10 12:40:42 2025 +0000 +++ b/mercurial/narrowspec.py Fri Jan 10 16:14:40 2025 +0000 @@ -84,6 +84,11 @@ _(b'"." and ".." are not allowed in narrowspec paths') ) + if pat != b'' and b'' in components: + raise error.Abort( + _(b'empty path components are not allowed in narrowspec paths') + ) + def normalizepattern(pattern, defaultkind=b'path'): """Returns the normalized version of a text-format pattern.
--- a/tests/test-narrow.t Fri Jan 10 12:40:42 2025 +0000 +++ b/tests/test-narrow.t Fri Jan 10 16:14:40 2025 +0000 @@ -62,6 +62,9 @@ $ hg clone --narrow ssh://user@dummy/master foo --include ' ' abort: leading or trailing whitespace is not allowed in narrowspec paths [255] + $ hg clone --narrow ssh://user@dummy/master foo --include 'a//c' + abort: empty path components are not allowed in narrowspec paths + [255] Names with '.' in them are OK. $ hg clone --narrow ./master should-work --include a/.b/c