diff options
| author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-18 11:43:23 (GMT) |
|---|---|---|
| committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-18 11:43:23 (GMT) |
| commit | ff1d2f4cc5a165b2d4dcc4b5abe6335cb3626e53 (patch) | |
| tree | 9e57aaf86c8a77c3d52420a7459c0ce0059efc52 /Lib/zipfile.py | |
| parent | 02a67ac72be5adb37431b18c3f4b7cb060be6e16 (diff) | |
| download | cpython-ff1d2f4cc5a165b2d4dcc4b5abe6335cb3626e53.zip cpython-ff1d2f4cc5a165b2d4dcc4b5abe6335cb3626e53.tar.gz cpython-ff1d2f4cc5a165b2d4dcc4b5abe6335cb3626e53.tar.bz2 | |
Backport commit 33543b4e0e5d from Python 3.2: #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 2ec6306..a382383 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -928,7 +928,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: raise BadZipfile( 'File name in directory %r and header %r differ.' % (zinfo.orig_filename, fname)) |
