Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 7553:71be8688f2db
audit: reject paths with .hg (issue 1450)
Spotted by Peter Arrenbrecht
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 31 Dec 2008 16:27:20 -0600 |
parents | 6a49fa7674c1 |
children | 016a7319e76b |
comparison
equal
deleted
inserted
replaced
7548:e8b818029ed6 | 7553:71be8688f2db |
---|---|
812 def __call__(self, path): | 812 def __call__(self, path): |
813 if path in self.audited: | 813 if path in self.audited: |
814 return | 814 return |
815 normpath = os.path.normcase(path) | 815 normpath = os.path.normcase(path) |
816 parts = splitpath(normpath) | 816 parts = splitpath(normpath) |
817 if (os.path.splitdrive(path)[0] or parts[0] in ('.hg', '') | 817 if (os.path.splitdrive(path)[0] or parts[0] in ('.hg', '.hg.', '') |
818 or os.pardir in parts): | 818 or os.pardir in parts): |
819 raise Abort(_("path contains illegal component: %s") % path) | 819 raise Abort(_("path contains illegal component: %s") % path) |
820 if '.hg' in path: | |
821 for p in '.hg', '.hg.': | |
822 if p in parts[1:-1]: | |
823 pos = parts.index(p) | |
824 base = os.path.join(*parts[:pos]) | |
825 raise Abort(_('path %r is inside repo %r') % (path, base)) | |
820 def check(prefix): | 826 def check(prefix): |
821 curpath = os.path.join(self.root, prefix) | 827 curpath = os.path.join(self.root, prefix) |
822 try: | 828 try: |
823 st = os.lstat(curpath) | 829 st = os.lstat(curpath) |
824 except OSError, err: | 830 except OSError, err: |