Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 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 | f5be619663f9 |
children | 6f011cf52f9a |
comparison
equal
deleted
inserted
replaced
13196:592998ba3466 | 13197:684a977c2ae0 |
---|---|
485 | 485 |
486 class path_auditor(object): | 486 class path_auditor(object): |
487 '''ensure that a filesystem path contains no banned components. | 487 '''ensure that a filesystem path contains no banned components. |
488 the following properties of a path are checked: | 488 the following properties of a path are checked: |
489 | 489 |
490 - ends with a directory separator | |
490 - under top-level .hg | 491 - under top-level .hg |
491 - starts at the root of a windows drive | 492 - starts at the root of a windows drive |
492 - contains ".." | 493 - contains ".." |
493 - traverses a symlink (e.g. a/symlink_here/b) | 494 - traverses a symlink (e.g. a/symlink_here/b) |
494 - inside a nested repository (a callback can be used to approve | 495 - inside a nested repository (a callback can be used to approve |
502 self.callback = callback | 503 self.callback = callback |
503 | 504 |
504 def __call__(self, path): | 505 def __call__(self, path): |
505 if path in self.audited: | 506 if path in self.audited: |
506 return | 507 return |
508 # AIX ignores "/" at end of path, others raise EISDIR. | |
509 if endswithsep(path): | |
510 raise Abort(_("path ends in directory separator: %s") % path) | |
507 normpath = os.path.normcase(path) | 511 normpath = os.path.normcase(path) |
508 parts = splitpath(normpath) | 512 parts = splitpath(normpath) |
509 if (os.path.splitdrive(path)[0] | 513 if (os.path.splitdrive(path)[0] |
510 or parts[0].lower() in ('.hg', '.hg.', '') | 514 or parts[0].lower() in ('.hg', '.hg.', '') |
511 or os.pardir in parts): | 515 or os.pardir in parts): |