Message365278
Updating the zip file comment to a shorter comment should truncate the zip file at the end of the new comment.
Instead, the new comment is written to the zip file but the file length stays the same.
For example, for a zip file that has the following zip comment:
b'This is my old amazing comment, I bet you really like it!' # 57 character long
Executing the following code:
zipFile = ZipFile(filePath, 'a')
zipFile.comment = b'My new shorter comment' # 22 character long
zipFile.close()
Will actually update the comment length in the zip header to the correct new length (22), but the bytecode will still have the following data:
b'My new shorter comment comment, I bet you really like it!'
Python reads the comment correctly since it relies on the comment length from the metadata (as far as I can tell), but the file is corrupt.
This is similar to the following old issue -
https://bugs.python.org/issue9239
But I wasn't sure whether to try and re-open that old one or create a new one.
Tested on version 3.8.2 (Windows 10).
Thanks! |
|
Date |
User |
Action |
Args |
2020-03-29 20:48:23 | yudilevi | set | recipients:
+ yudilevi |
2020-03-29 20:48:23 | yudilevi | set | messageid: <1585514903.71.0.609611507951.issue40105@roundup.psfhosted.org> |
2020-03-29 20:48:23 | yudilevi | link | issue40105 messages |
2020-03-29 20:48:23 | yudilevi | create | |
|