@@ -2173,12 +2173,13 @@ def test_unpack_archive_zip_badpaths(self):
21732173 with zipfile .ZipFile (zipname , 'w' ) as zf :
21742174 zf .writestr (abspath , 'badfile' )
21752175 zf .writestr (os .sep + abspath , 'badfile' )
2176- zf .writestr ('/abspath2' , 'badfile' )
2177- if os .name == 'nt' :
2178- zf .writestr ('C:/abspath3' , 'badfile' )
2179- zf .writestr ('C:\\ abspath4' , 'badfile' )
2180- zf .writestr ('C:abspath5' , 'badfile' )
2181- zf .writestr ('C:/C:/abspath6' , 'badfile' )
2176+ zf .writestr ('/abspath' , 'badfile' )
2177+ zf .writestr ('C:/abspath' , 'badfile' )
2178+ zf .writestr ('D:\\ abspath' , 'badfile' )
2179+ zf .writestr ('E:abspath' , 'badfile' )
2180+ zf .writestr ('F:/G:/abspath' , 'badfile' )
2181+ zf .writestr ('//server/share/abspath' , 'badfile' )
2182+ zf .writestr ('\\ \\ server2\\ share\\ abspath' , 'badfile' )
21822183 zf .writestr ('../relpath' , 'badfile' )
21832184 zf .writestr (os .pardir + os .sep + 'relpath2' , 'badfile' )
21842185 zf .writestr ('good/file' , 'goodfile' )
@@ -2189,16 +2190,22 @@ def test_unpack_archive_zip_badpaths(self):
21892190 self .assertTrue (os .path .isfile (os .path .join (dstdir , 'good' , 'file' )))
21902191 self .assertTrue (os .path .isfile (os .path .join (dstdir , 'good..file' )))
21912192 self .assertFalse (os .path .exists (abspath ))
2192- self .assertTrue (os .path .exists (os .path .join (dstdir , 'abspath2' )))
2193- if os .name == 'nt' :
2194- self .assertTrue (os .path .exists (os .path .join (dstdir , 'abspath3' )))
2195- self .assertTrue (os .path .exists (os .path .join (dstdir , 'abspath4' )))
2196- self .assertTrue (os .path .exists (os .path .join (dstdir , 'abspath5' )))
2197- self .assertTrue (os .path .exists (os .path .join (dstdir , 'C_' , 'abspath6' )))
2198- self .assertFalse (os .path .exists (os .path .join (dstdir , '..' , 'relpath' )))
2199- self .assertTrue (os .path .exists (os .path .join (dstdir , 'relpath' )))
2193+ self .assertFalse (os .path .exists (os .path .join (dstdir , 'abspath' )))
2194+ self .assertFalse (os .path .exists (os .path .join (dstdir , 'G_' )))
2195+ self .assertFalse (os .path .exists (os .path .join (dstdir , 'server' )))
2196+ if os .name != 'nt' :
2197+ self .assertTrue (os .path .isfile (os .path .join (dstdir , 'C:' , 'abspath' )))
2198+ self .assertTrue (os .path .isfile (os .path .join (dstdir , 'D:\\ abspath' )))
2199+ self .assertTrue (os .path .isfile (os .path .join (dstdir , 'E:abspath' )))
2200+ self .assertTrue (os .path .isfile (os .path .join (dstdir , 'F:' , 'G:' , 'abspath' )))
2201+ self .assertTrue (os .path .isfile (os .path .join (dstdir , '\\ \\ server2\\ share\\ abspath' )))
2202+ if os .pardir == '..' :
2203+ self .assertFalse (os .path .exists (os .path .join (dstdir , '..' , 'relpath' )))
2204+ self .assertFalse (os .path .exists (os .path .join (dstdir , 'relpath' )))
2205+ else :
2206+ self .assertTrue (os .path .isfile (os .path .join (dstdir , '..' , 'relpath' )))
22002207 self .assertFalse (os .path .exists (os .path .join (dstdir , os .pardir , 'relpath2' )))
2201- self .assertTrue (os .path .exists (os .path .join (dstdir , 'relpath2' )))
2208+ self .assertFalse (os .path .exists (os .path .join (dstdir , 'relpath2' )))
22022209
22032210 dstdir2 = os .path .join (self .mkdtemp (), 'dst' )
22042211 os .mkdir (dstdir2 )
@@ -2207,16 +2214,22 @@ def test_unpack_archive_zip_badpaths(self):
22072214 self .assertTrue (os .path .isfile (os .path .join ('good' , 'file' )))
22082215 self .assertTrue (os .path .isfile ('good..file' ))
22092216 self .assertFalse (os .path .exists (abspath ))
2210- self .assertTrue (os .path .exists ('abspath2' ))
2211- if os .name == 'nt' :
2212- self .assertTrue (os .path .exists ('abspath3' ))
2213- self .assertTrue (os .path .exists ('abspath4' ))
2214- self .assertTrue (os .path .exists ('abspath5' ))
2215- self .assertTrue (os .path .exists (os .path .join ('c_' , 'abspath6' )))
2216- self .assertFalse (os .path .exists (os .path .join ('..' , 'relpath' )))
2217- self .assertTrue (os .path .exists ('relpath' ))
2217+ self .assertFalse (os .path .exists ('abspath' ))
2218+ self .assertFalse (os .path .exists ('C_' ))
2219+ self .assertFalse (os .path .exists ('server' ))
2220+ if os .name != 'nt' :
2221+ self .assertTrue (os .path .isfile (os .path .join ('C:' , 'abspath' )))
2222+ self .assertTrue (os .path .isfile ('D:\\ abspath' ))
2223+ self .assertTrue (os .path .isfile ('E:abspath' ))
2224+ self .assertTrue (os .path .isfile (os .path .join ('F:' , 'G:' , 'abspath' )))
2225+ self .assertTrue (os .path .isfile ('\\ \\ server2\\ share\\ abspath' ))
2226+ if os .pardir == '..' :
2227+ self .assertFalse (os .path .exists (os .path .join ('..' , 'relpath' )))
2228+ self .assertFalse (os .path .exists ('relpath' ))
2229+ else :
2230+ self .assertTrue (os .path .isfile (os .path .join ('..' , 'relpath' )))
22182231 self .assertFalse (os .path .exists (os .path .join (os .pardir , 'relpath2' )))
2219- self .assertTrue (os .path .exists ('relpath2' ))
2232+ self .assertFalse (os .path .exists ('relpath2' ))
22202233
22212234 def test_unpack_registry (self ):
22222235
0 commit comments