safe_join on Windows uses posixpath

fixes #2033
closes #2059
This commit is contained in:
David Lord 2017-05-15 16:58:01 -07:00
parent 88120e9e9d
commit 2a65794306
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
2 changed files with 26 additions and 21 deletions

View file

@ -903,21 +903,20 @@ class TestStreaming(object):
class TestSafeJoin(object):
def test_safe_join(self):
# Valid combinations of *args and expected joined paths.
passing = (
(('a/b/c', ), 'a/b/c'),
(('/', 'a/', 'b/', 'c/', ), '/a/b/c'),
(('a', 'b', 'c', ), 'a/b/c'),
(('/a', 'b/c', ), '/a/b/c'),
(('a/b', 'X/../c'), 'a/b/c', ),
(('/a/b', 'c/X/..'), '/a/b/c', ),
(('a/b/c',), 'a/b/c'),
(('/', 'a/', 'b/', 'c/'), '/a/b/c'),
(('a', 'b', 'c'), 'a/b/c'),
(('/a', 'b/c'), '/a/b/c'),
(('a/b', 'X/../c'), 'a/b/c'),
(('/a/b', 'c/X/..'), '/a/b/c'),
# If last path is '' add a slash
(('/a/b/c', '', ), '/a/b/c/', ),
(('/a/b/c', ''), '/a/b/c/'),
# Preserve dot slash
(('/a/b/c', './', ), '/a/b/c/.', ),
(('a/b/c', 'X/..'), 'a/b/c/.', ),
(('/a/b/c', './'), '/a/b/c/.'),
(('a/b/c', 'X/..'), 'a/b/c/.'),
# Base directory is always considered safe
(('../', 'a/b/c'), '../a/b/c'),
(('/..', ), '/..'),
@ -931,12 +930,12 @@ class TestSafeJoin(object):
failing = (
# path.isabs and ``..'' checks
('/a', 'b', '/c'),
('/a', '../b/c', ),
('/a', '../b/c'),
('/a', '..', 'b/c'),
# Boundaries violations after path normalization
('/a', 'b/../b/../../c', ),
('/a', 'b/../b/../../c'),
('/a', 'b', 'c/../..'),
('/a', 'b/../../c', ),
('/a', 'b/../../c'),
)
for args in failing: