cpython: 7a47fd7f2fdc (original) (raw)

--- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@ -548,8 +548,6 @@ class TestsWithSourceFile(unittest.TestC ('/foo/bar', 'foo/bar'), ('/foo/../bar', 'foo/bar'), ('/foo/../../bar', 'foo/bar'),

@@ -571,19 +569,32 @@ class TestsWithSourceFile(unittest.TestC (r'\?\C:\foo\bar', 'foo/bar'), (r'C:/../C:/foo/bar', 'C_/foo/bar'), (r'a:b\ce|f"g?h*i', 'b/c_d_e_f_g_h_i'),

for arcname, fixedname in hacknames: content = b'foobar' + arcname.encode() with zipfile.ZipFile(TESTFN2, 'w', zipfile.ZIP_STORED) as zipfp:

with zipfile.ZipFile(TESTFN2, 'r') as zipfp: writtenfile = zipfp.extract(arcname, targetpath)

@@ -596,7 +607,8 @@ class TestsWithSourceFile(unittest.TestC with zipfile.ZipFile(TESTFN2, 'r') as zipfp: writtenfile = zipfp.extract(arcname)

--- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -1238,11 +1238,14 @@ class ZipFile: arcname = os.path.splitdrive(arcname)[1] arcname = os.path.sep.join(x for x in arcname.split(os.path.sep) if x not in ('', os.path.curdir, os.path.pardir))

targetpath = os.path.join(targetpath, arcname) targetpath = os.path.normpath(targetpath)