diff options
Diffstat (limited to 'lib-python/3/test/test_zipfile.py')
-rw-r--r-- | lib-python/3/test/test_zipfile.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib-python/3/test/test_zipfile.py b/lib-python/3/test/test_zipfile.py index 9566a72a40..9b08d5647e 100644 --- a/lib-python/3/test/test_zipfile.py +++ b/lib-python/3/test/test_zipfile.py @@ -3222,6 +3222,23 @@ with zipfile.ZipFile(io.BytesIO(), "w") as zf: zipfile.Path(zf) zf.extractall(source_path.parent) + def test_malformed_paths(self): + """ + Path should handle malformed paths. + """ + data = io.BytesIO() + zf = zipfile.ZipFile(data, "w") + zf.writestr("/one-slash.txt", b"content") + zf.writestr("//two-slash.txt", b"content") + zf.writestr("../parent.txt", b"content") + zf.filename = '' + root = zipfile.Path(zf) + assert list(map(str, root.iterdir())) == [ + 'one-slash.txt', + 'two-slash.txt', + 'parent.txt', + ] + class StripExtraTests(unittest.TestCase): # Note: all of the "z" characters are technically invalid, but up |