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