Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bpo-6839: removed unnecessary file name encoding test from ZipFile.open
  • Loading branch information
MorganRamsay committed Jun 18, 2019
commit 804aaec0fd790eed05715920b514811b9d5cfa12
13 changes: 1 addition & 12 deletions Lib/zipfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,7 @@ def open(self, name, mode="r", pwd=None, *, force_zip64=False):
if fheader[_FH_SIGNATURE] != stringFileHeader:
raise BadZipFile("Bad magic number for file header")

fname = zef_file.read(fheader[_FH_FILENAME_LENGTH])
zef_file.read(fheader[_FH_FILENAME_LENGTH])
if fheader[_FH_EXTRA_FIELD_LENGTH]:
zef_file.read(fheader[_FH_EXTRA_FIELD_LENGTH])

Expand All @@ -1509,17 +1509,6 @@ def open(self, name, mode="r", pwd=None, *, force_zip64=False):
# strong encryption
raise NotImplementedError("strong encryption (flag bit 6)")

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))

# check for encrypted flag & handle password
is_encrypted = zinfo.flag_bits & 0x1
zd = None
Expand Down