From 79a309fe54dc6b7934fb72e9f31bcb58f2e9f547 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 31 May 2024 11:20:57 -0400 Subject: [PATCH] Add some assertions about malformed paths. --- tests/test_path.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_path.py b/tests/test_path.py index bbf39b2..53f8848 100644 --- a/tests/test_path.py +++ b/tests/test_path.py @@ -571,3 +571,21 @@ def test_getinfo_missing(self, alpharep): zipfile.Path(alpharep) with self.assertRaises(KeyError): alpharep.getinfo('does-not-exist') + + @__import__('pytest').mark.skip(reason="infinite loop") + 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', + ]