Formats MUST write archives byte for byte from the files alone (a ustar tar, a gzip of stored blocks, a zip of stored entries, in the byte order of their paths, with fixed times and modes); where asked, a zip of deflated entries (method 8, through the web standard CompressionStream("deflate-raw"), an entry stored where deflate would not shrink it), the same bytes for the same files on one runtime and the same files unzipped on every runtime (the deflaters of Node and Bun may choose different bytes, and do); and read them (tar with pax and GNU long names, gzip and zip entries stored or deflated through DecompressionStream), checking each header checksum, CRC-32 and size, and refusing every path that is absolute, has a .., . or empty segment, a backslash, a drive letter or a NUL.
Enforced (check): .github: cd commons/formats && bun test suite/ — archive.test.ts: round trips of tar, zip and gzip, fixed bytes, unsafe and damaged archives, deflated zip read and written, pax and GNU names
Proved by: formats/suite/archive.test.ts
Written in: formats/src/archive.ts
Tests: passed: suite/archive.test.ts a zip of deflated entries: the files back, the same bytes twice, stored where deflate woul; passed: suite/archive.test.ts tar then untar gives the files back, the same bytes every time; passed: suite/archive.test.ts zip then unzip, and gzip then gunzip, give the bytes back; passed: suite/archive.test.ts a damaged archive is refused: a tar checksum, a zip CRC, a truncated stream; passed: suite/archive.test.ts a long path is split into the ustar prefix and name; one that cannot be is refused and 6 more
Cited by: archive, Formats