mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-117084: Fix ZIP file extraction for directory entry names with backslashes on Windows (GH-117129)
This commit is contained in:
parent
5a78f6e798
commit
567ab3bd15
4 changed files with 27 additions and 1 deletions
|
@ -605,7 +605,15 @@ class ZipInfo:
|
|||
|
||||
def is_dir(self):
|
||||
"""Return True if this archive member is a directory."""
|
||||
return self.filename.endswith('/')
|
||||
if self.filename.endswith('/'):
|
||||
return True
|
||||
# The ZIP format specification requires to use forward slashes
|
||||
# as the directory separator, but in practice some ZIP files
|
||||
# created on Windows can use backward slashes. For compatibility
|
||||
# with the extraction code which already handles this:
|
||||
if os.path.altsep:
|
||||
return self.filename.endswith((os.path.sep, os.path.altsep))
|
||||
return False
|
||||
|
||||
|
||||
# ZIP encryption uses the CRC32 one-byte primitive for scrambling some
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue