Skip to content

Commit 79a309f

Browse files
committed
Add some assertions about malformed paths.
1 parent 2d015c2 commit 79a309f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/test_path.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,3 +571,21 @@ def test_getinfo_missing(self, alpharep):
571571
zipfile.Path(alpharep)
572572
with self.assertRaises(KeyError):
573573
alpharep.getinfo('does-not-exist')
574+
575+
@__import__('pytest').mark.skip(reason="infinite loop")
576+
def test_malformed_paths(self):
577+
"""
578+
Path should handle malformed paths.
579+
"""
580+
data = io.BytesIO()
581+
zf = zipfile.ZipFile(data, "w")
582+
zf.writestr("/one-slash.txt", b"content")
583+
zf.writestr("//two-slash.txt", b"content")
584+
zf.writestr("../parent.txt", b"content")
585+
zf.filename = ''
586+
root = zipfile.Path(zf)
587+
assert list(map(str, root.iterdir())) == [
588+
'one-slash.txt',
589+
'two-slash.txt',
590+
'parent.txt',
591+
]

0 commit comments

Comments
 (0)