mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
UNzipping zip files: Workaround invalid zip files that contain end-of-file comments but set comment size to zero. Baen seems to be particularly fond of generating these
This commit is contained in:
parent
f587a7e825
commit
a0671a64d4
@ -222,7 +222,8 @@ def _EndRecData(fpin):
|
|||||||
endrec = list(struct.unpack(structEndArchive, recData))
|
endrec = list(struct.unpack(structEndArchive, recData))
|
||||||
comment = data[start+sizeEndCentDir:]
|
comment = data[start+sizeEndCentDir:]
|
||||||
# check that comment length is correct
|
# check that comment length is correct
|
||||||
if endrec[_ECD_COMMENT_SIZE] == len(comment):
|
# Kovid: Added == 0 check as some zip files apparently dont set this
|
||||||
|
if endrec[_ECD_COMMENT_SIZE] == 0 or endrec[_ECD_COMMENT_SIZE] == len(comment):
|
||||||
# Append the archive comment and start offset
|
# Append the archive comment and start offset
|
||||||
endrec.append(comment)
|
endrec.append(comment)
|
||||||
endrec.append(maxCommentStart + start)
|
endrec.append(maxCommentStart + start)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user