changeset 13197:684a977c2ae0

opener: forbid paths ending with directory separator (issue2507) If Linux is asked to open a filename with a trailing directory separator, e.g. "foo/", the open fails with EISDIR. On AIX, the open succeeds, opening file "foo". This causes test-mq-qnew to fail on AIX. Fix by adding 'ends with directory separator' to the conditions checked by the path auditor. Change test to expect auditor fail message.
author Jim Hague <jim.hague@acm.org>
date Fri, 17 Dec 2010 12:05:45 +0000
parents 592998ba3466
children e71b2aa74ce3
files mercurial/util.py tests/test-mq-qnew.t
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Tue Dec 21 15:27:58 2010 -0600
+++ b/mercurial/util.py	Fri Dec 17 12:05:45 2010 +0000
@@ -487,6 +487,7 @@
     '''ensure that a filesystem path contains no banned components.
     the following properties of a path are checked:
 
+    - ends with a directory separator
     - under top-level .hg
     - starts at the root of a windows drive
     - contains ".."
@@ -504,6 +505,9 @@
     def __call__(self, path):
         if path in self.audited:
             return
+        # AIX ignores "/" at end of path, others raise EISDIR.
+        if endswithsep(path):
+            raise Abort(_("path ends in directory separator: %s") % path)
         normpath = os.path.normcase(path)
         parts = splitpath(normpath)
         if (os.path.splitdrive(path)[0]
--- a/tests/test-mq-qnew.t	Tue Dec 21 15:27:58 2010 -0600
+++ b/tests/test-mq-qnew.t	Fri Dec 17 12:05:45 2010 +0000
@@ -107,7 +107,7 @@
   abort: "foo#bar" cannot be used as the name of a patch
   abort: "foo:bar" cannot be used as the name of a patch
   % qnew with name containing slash
-  abort: cannot write patch "foo/": (Is a|No such file or) directory (re)
+  abort: path ends in directory separator: foo/
   abort: "foo" already exists as a directory
   foo/bar.patch
   popping foo/bar.patch
@@ -172,7 +172,7 @@
   abort: "foo#bar" cannot be used as the name of a patch
   abort: "foo:bar" cannot be used as the name of a patch
   % qnew with name containing slash
-  abort: cannot write patch "foo/": (Is a|No such file or) directory (re)
+  abort: path ends in directory separator: foo/
   abort: "foo" already exists as a directory
   foo/bar.patch
   popping foo/bar.patch