diff options
author | Georg Brandl <georg@python.org> | 2011-01-01 10:09:32 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2011-01-01 10:09:32 (GMT) |
commit | 5ba11de8454b7dbc1cf260911a2628608267a50c (patch) | |
tree | 1677c9be0261289540532af66acd17d8b663a36a /Lib/zipfile.py | |
parent | d30a0dd681d82251dc3611c49d6a2d9ce2e48e5c (diff) | |
download | cpython-5ba11de8454b7dbc1cf260911a2628608267a50c.zip cpython-5ba11de8454b7dbc1cf260911a2628608267a50c.tar.gz cpython-5ba11de8454b7dbc1cf260911a2628608267a50c.tar.bz2 |
#10801: In zipfile, support different encodings for the header and the filenames. Patch by MvL, test by Eli Bendersky.
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r-- | Lib/zipfile.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py index 197f0bc..50f4848 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -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( |