@@ -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,23 @@ 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+ self .assertFalse (os .path .exists (os .path .join (dstdir , 'server2' )))
2197+ if os .name != 'nt' :
2198+ self .assertTrue (os .path .isfile (os .path .join (dstdir , 'C:' , 'abspath' )))
2199+ self .assertTrue (os .path .isfile (os .path .join (dstdir , 'D:\\ abspath' )))
2200+ self .assertTrue (os .path .isfile (os .path .join (dstdir , 'E:abspath' )))
2201+ self .assertTrue (os .path .isfile (os .path .join (dstdir , 'F:' , 'G:' , 'abspath' )))
2202+ self .assertTrue (os .path .isfile (os .path .join (dstdir , '\\ \\ server2\\ share\\ abspath' )))
2203+ if os .pardir == '..' :
2204+ self .assertFalse (os .path .exists (os .path .join (dstdir , '..' , 'relpath' )))
2205+ self .assertFalse (os .path .exists (os .path .join (dstdir , 'relpath' )))
2206+ else :
2207+ self .assertTrue (os .path .isfile (os .path .join (dstdir , '..' , 'relpath' )))
22002208 self .assertFalse (os .path .exists (os .path .join (dstdir , os .pardir , 'relpath2' )))
2201- self .assertTrue (os .path .exists (os .path .join (dstdir , 'relpath2' )))
2209+ self .assertFalse (os .path .exists (os .path .join (dstdir , 'relpath2' )))
22022210
22032211 dstdir2 = os .path .join (self .mkdtemp (), 'dst' )
22042212 os .mkdir (dstdir2 )
@@ -2207,16 +2215,23 @@ def test_unpack_archive_zip_badpaths(self):
22072215 self .assertTrue (os .path .isfile (os .path .join ('good' , 'file' )))
22082216 self .assertTrue (os .path .isfile ('good..file' ))
22092217 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' ))
2218+ self .assertFalse (os .path .exists ('abspath' ))
2219+ self .assertFalse (os .path .exists ('C_' ))
2220+ self .assertFalse (os .path .exists ('server' ))
2221+ self .assertFalse (os .path .exists ('server2' ))
2222+ if os .name != 'nt' :
2223+ self .assertTrue (os .path .isfile (os .path .join ('C:' , 'abspath' )))
2224+ self .assertTrue (os .path .isfile ('D:\\ abspath' ))
2225+ self .assertTrue (os .path .isfile ('E:abspath' ))
2226+ self .assertTrue (os .path .isfile (os .path .join ('F:' , 'G:' , 'abspath' )))
2227+ self .assertTrue (os .path .isfile ('\\ \\ server2\\ share\\ abspath' ))
2228+ if os .pardir == '..' :
2229+ self .assertFalse (os .path .exists (os .path .join ('..' , 'relpath' )))
2230+ self .assertFalse (os .path .exists ('relpath' ))
2231+ else :
2232+ self .assertTrue (os .path .isfile (os .path .join ('..' , 'relpath' )))
22182233 self .assertFalse (os .path .exists (os .path .join (os .pardir , 'relpath2' )))
2219- self .assertTrue (os .path .exists ('relpath2' ))
2234+ self .assertFalse (os .path .exists ('relpath2' ))
22202235
22212236 def test_unpack_registry (self ):
22222237
0 commit comments