changeset 47808:23921bc857b5 stable

subrepo: compare normalised vfs path Otherwise the realpath call can turn `/` into `\` on windows confusing the check. (We probably needs this in more location) Differential Revision: https://phab.mercurial-scm.org/D11259
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 05 Aug 2021 12:53:36 +0200
parents bc74cb9a8e40
children 98c3fa6a3ac2
files mercurial/subrepo.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Thu Aug 05 18:25:35 2021 +0200
+++ b/mercurial/subrepo.py	Thu Aug 05 12:53:36 2021 +0200
@@ -458,12 +458,14 @@
         create = allowcreate and not r.wvfs.exists(b'%s/.hg' % path)
         # repository constructor does expand variables in path, which is
         # unsafe since subrepo path might come from untrusted source.
-        if os.path.realpath(util.expandpath(root)) != root:
+        norm_root = os.path.normcase(root)
+        real_root = os.path.normcase(os.path.realpath(util.expandpath(root)))
+        if real_root != norm_root:
             raise error.Abort(
                 _(b'subrepo path contains illegal component: %s') % path
             )
         self._repo = hg.repository(r.baseui, root, create=create)
-        if self._repo.root != root:
+        if os.path.normcase(self._repo.root) != os.path.normcase(root):
             raise error.ProgrammingError(
                 b'failed to reject unsafe subrepo '
                 b'path: %s (expanded to %s)' % (root, self._repo.root)