mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
#10801: In zipfile, support different encodings for the header and the filenames. Patch by MvL, test by Eli Bendersky.
This commit is contained in:
parent
d30a0dd681
commit
5ba11de845
4 changed files with 24 additions and 1 deletions
|
@ -930,7 +930,13 @@ class ZipFile:
|
|||
if fheader[_FH_EXTRA_FIELD_LENGTH]:
|
||||
zef_file.read(fheader[_FH_EXTRA_FIELD_LENGTH])
|
||||
|
||||
if fname != zinfo.orig_filename.encode("utf-8"):
|
||||
if zinfo.flag_bits & 0x800:
|
||||
# UTF-8 filename
|
||||
fname_str = fname.decode("utf-8")
|
||||
else:
|
||||
fname_str = fname.decode("cp437")
|
||||
|
||||
if fname_str != zinfo.orig_filename:
|
||||
if not self._filePassed:
|
||||
zef_file.close()
|
||||
raise BadZipFile(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue