Description
remotezip -l fails with a ValueError when a ZIP archive contains entries whose DOS timestamp has an invalid month or day value.
For example, an archive may contain entries with a timestamp such as:
Running:
remotezip -l https://example.com/example.zip
results in:
Traceback (most recent call last):
...
dt = datetime(*zinfo.date_time)
ValueError: month must be in 1..12
The archive itself can still be read normally by standard ZIP tools; the problem is caused by _list_files() converting ZipInfo.date_time to a datetime object solely for display.
Suggested fix
Since the timestamp is only used for display, _list_files() could format the values in ZipInfo.date_time directly instead of converting them to datetime.
For example:
Y, m, d, H, M, S = zinfo.date_time
data.append((
zinfo.file_size,
f"{Y:04d}-{m:02d}-{d:02d} {H:02d}:{M:02d}:{S:02d}",
zinfo.filename
))
This preserves the existing output format while allowing archives with non-standard or invalid DOS date fields to be listed.
I would be happy to submit a pull request for this change.
Description
remotezip -lfails with aValueErrorwhen a ZIP archive contains entries whose DOS timestamp has an invalid month or day value.For example, an archive may contain entries with a timestamp such as:
Running:
results in:
The archive itself can still be read normally by standard ZIP tools; the problem is caused by
_list_files()convertingZipInfo.date_timeto adatetimeobject solely for display.Suggested fix
Since the timestamp is only used for display,
_list_files()could format the values inZipInfo.date_timedirectly instead of converting them todatetime.For example:
This preserves the existing output format while allowing archives with non-standard or invalid DOS date fields to be listed.
I would be happy to submit a pull request for this change.