Mercurial > hg
comparison mercurial/subrepo.py @ 41583:87a6e3c953e0 stable
subrepo: avoid false unsafe path detection on Windows
Subrepo paths are not normalized for the OS, so what was happening in the
subsequent root path check was:
root -> $TESTTMP\issue1852a\sub/repo
util.expandpath(...) -> $TESTTMP\issue1852a\sub/repo
os.path.realpath(...) -> $TESTTMP\issue1852a\sub\repo
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 05 Feb 2019 20:50:54 -0500 |
parents | 83377b4b4ae0 |
children | 91701785c2c5 |
comparison
equal
deleted
inserted
replaced
41460:8b2892d5a9f2 | 41583:87a6e3c953e0 |
---|---|
403 class hgsubrepo(abstractsubrepo): | 403 class hgsubrepo(abstractsubrepo): |
404 def __init__(self, ctx, path, state, allowcreate): | 404 def __init__(self, ctx, path, state, allowcreate): |
405 super(hgsubrepo, self).__init__(ctx, path) | 405 super(hgsubrepo, self).__init__(ctx, path) |
406 self._state = state | 406 self._state = state |
407 r = ctx.repo() | 407 r = ctx.repo() |
408 root = r.wjoin(path) | 408 root = r.wjoin(util.localpath(path)) |
409 create = allowcreate and not r.wvfs.exists('%s/.hg' % path) | 409 create = allowcreate and not r.wvfs.exists('%s/.hg' % path) |
410 # repository constructor does expand variables in path, which is | 410 # repository constructor does expand variables in path, which is |
411 # unsafe since subrepo path might come from untrusted source. | 411 # unsafe since subrepo path might come from untrusted source. |
412 if os.path.realpath(util.expandpath(root)) != root: | 412 if os.path.realpath(util.expandpath(root)) != root: |
413 raise error.Abort(_('subrepo path contains illegal component: %s') | 413 raise error.Abort(_('subrepo path contains illegal component: %s') |