mercurial/subrepo.py
branchstable
changeset 41457 6c10eba6b9cd
parent 40753 9199548525fc
child 41458 83377b4b4ae0
equal deleted inserted replaced
41456:31286c9282df 41457:6c10eba6b9cd
   401         super(hgsubrepo, self).__init__(ctx, path)
   401         super(hgsubrepo, self).__init__(ctx, path)
   402         self._state = state
   402         self._state = state
   403         r = ctx.repo()
   403         r = ctx.repo()
   404         root = r.wjoin(path)
   404         root = r.wjoin(path)
   405         create = allowcreate and not r.wvfs.exists('%s/.hg' % path)
   405         create = allowcreate and not r.wvfs.exists('%s/.hg' % path)
       
   406         # repository constructor does expand variables in path, which is
       
   407         # unsafe since subrepo path might come from untrusted source.
       
   408         if os.path.realpath(util.expandpath(root)) != root:
       
   409             raise error.Abort(_('subrepo path contains illegal component: %s')
       
   410                               % path)
   406         self._repo = hg.repository(r.baseui, root, create=create)
   411         self._repo = hg.repository(r.baseui, root, create=create)
       
   412         if self._repo.root != root:
       
   413             raise error.ProgrammingError('failed to reject unsafe subrepo '
       
   414                                          'path: %s (expanded to %s)'
       
   415                                          % (root, self._repo.root))
   407 
   416 
   408         # Propagate the parent's --hidden option
   417         # Propagate the parent's --hidden option
   409         if r is r.unfiltered():
   418         if r is r.unfiltered():
   410             self._repo = self._repo.unfiltered()
   419             self._repo = self._repo.unfiltered()
   411 
   420