diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py --- a/mercurial/hgweb/common.py +++ b/mercurial/hgweb/common.py @@ -138,7 +138,7 @@ def ispathsafe(path): """Determine if a path is safe to use for filesystem access.""" parts = path.split('/') for part in parts: - if (part in ('', os.curdir, os.pardir) or + if (part in ('', os.curdir, pycompat.ospardir) or pycompat.ossep in part or pycompat.osaltsep is not None and pycompat.osaltsep in part): return False diff --git a/mercurial/pathutil.py b/mercurial/pathutil.py --- a/mercurial/pathutil.py +++ b/mercurial/pathutil.py @@ -65,7 +65,7 @@ class pathauditor(object): parts = util.splitpath(path) if (os.path.splitdrive(path)[0] or _lowerclean(parts[0]) in ('.hg', '.hg.', '') - or os.pardir in parts): + or pycompat.ospardir in parts): raise error.Abort(_("path contains illegal component: %s") % path) # Windows shortname aliases for p in parts: diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -51,6 +51,7 @@ if ispy3: oslinesep = os.linesep.encode('ascii') osname = os.name.encode('ascii') ospathsep = os.pathsep.encode('ascii') + ospardir = os.pardir.encode('ascii') ossep = os.sep.encode('ascii') osaltsep = os.altsep if osaltsep: @@ -323,6 +324,7 @@ else: oslinesep = os.linesep osname = os.name ospathsep = os.pathsep + ospardir = os.pardir ossep = os.sep osaltsep = os.altsep stdin = sys.stdin diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -1600,7 +1600,7 @@ def stylemap(styles, paths=None): for style in styles: # only plain name is allowed to honor template paths if (not style - or style in (os.curdir, os.pardir) + or style in (os.curdir, pycompat.ospardir) or pycompat.ossep in style or pycompat.osaltsep and pycompat.osaltsep in style): continue