Repository navigation
Clamp file dates outside the DOS date range - #980
Open
mkantautas wants to merge 1 commit into
Open
mkantautas wants to merge 1 commit into
mkantautas wants to merge 1 commit into
Conversation
The DOS date fields only store the years 1980 to 2107, and the year was written modulo 128. A date before 1980, such as new Date(0), was saved as 2098-01-01 and a date in 2108 was saved as 1980. Save earlier dates as 1980-01-01 00:00:00 UTC and later dates as 2107-12-31 23:59:58 UTC, and document the range.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The DOS date fields of a zip entry only hold the years 1980 to 2107. The generator writes
date.getUTCFullYear() - 1980into the 7-bit year field without a range check, so the year wraps around modulo 128:zipinfoand Python'szipfilealso read 2098-01-01 for that entry. A date in 2108 is saved as 1980.new Date(1980, 0, 1), which some projects pass as a fixed date for reproducible archives, hits the same wrap in timezones east of UTC: it is 1979-12-31 in UTC, so the entry is saved as 2107-12-31.This change saves dates before 1980 as 1980-01-01 00:00:00 UTC and dates after 2107 as 2107-12-31 23:59:58 UTC. Python's
zipfiledoes the same withstrict_timestamps=False, and Info-ZIPzipalso saves dates before 1980 as 1980-01-01. The date on theZipObjectis not changed. Thedateoption documentation states the range. The UTC versus local time question in #369 is separate.The new test in
test/asserts/file.jsfails onmainand passes with the change.npm run lint,npm run test-nodeon Node.js 6 to 26 andnpm run test-browser(Chromium, Firefox, WebKit) pass.