summaryrefslogtreecommitdiff
path: root/Lib/zipfile.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2011-01-01 10:09:32 +0000
committerGeorg Brandl <georg@python.org>2011-01-01 10:09:32 +0000
commitc14f4cf0e0c25ba38d691a957f2f9b9b468fcc96 (patch)
tree7ed69e5ae94c008f36bb33dc5ece7ecf0864253b /Lib/zipfile.py
parent6b92f0f3b9cb8cc1cdc998d972cc4c5730a9dd64 (diff)
downloadcpython-c14f4cf0e0c25ba38d691a957f2f9b9b468fcc96.tar.gz
#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.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index 197f0bc6e1..50f484873a 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(