What's Changed in v2.8.50
New features
- New
filenameValidationoption inZipReaderandgetEntries(). It rejects entry names that do not map safely to a file path. It accepts"strict","balanced"and"tolerant", and defaults to the value of thestrictnessoption. Rejected names throw the newERR_UNSAFE_FILENAMEerror, which carries the offending name in itsfilenameproperty - New
normalizeFilenameoption inZipReaderandgetEntries(). It is called with the decoded name of each entry and its result replaces that name. It runs after decoding and before validation, so repairing a name is enough to make it passfilenameValidation. Returningundefinedkeeps the decoded name. The filesystem API inherits the option fromZipReaderConstructorOptions - The
decodeTextandencodeTextoptions now receive the type of the text they handle,"filename"or"comment", as their last argument. Hooks declaring fewer parameters keep working exportFileSystemHandle()now reports what happened when an export fails. The newentryNameproperty ofEntryErrorholds the name of the entry that failed, relative to the exported entry. The newexportedEntryNamesproperty lists the files that were completely written before the failure. Every other file of the export is either missing or empty, so this is the only way to tell a file the export completed from one it created but never filledexportFileSystemHandle()called withconcurrentset totruenow collects every failure instead of reporting only the first one. The other failures are listed in the newentryErrorsproperty ofEntryError. Failures raised deeper in the tree are flattened into that list- New
ERR_INVALID_LEVEL,ERR_INVALID_PASSWORD_TYPE,ERR_INVALID_STRICTNESS,ERR_INVALID_FILENAME_VALIDATIONandERR_INVALID_MAX_APPENDED_DATA_SIZEerror constants
Breaking changes
- Entry names containing a
..path component, or starting with/, with a drive letter likeC:, or with\\, are now rejected when reading an archive. They throwERR_UNSAFE_FILENAME. SetfilenameValidationto"tolerant"to restore the previous behavior. This default was verified against a corpus of 572 archives holding 257,333 entries. None of them was rejected, so the new default costs nothing on real archives. A backslash is never treated as a path separator. It is legal on UNIX file systems, and it also occurs as the trail byte of double-byte filenames in Shift-JIS, Big5 and GBK, where converting it would corrupt the name - The
strictnessoption set to"strict"now also rejects empty and.path components, e.g.a//b.txtand./cur.txt - Invalid option values now throw instead of falling back silently to a default. A
leveloutside the integers 0 to 9 throwsERR_INVALID_LEVEL, and used to disable compression entirely when it was negative or not a number. Apasswordthat is not a string, or arawPasswordthat is not aUint8Array, throwsERR_INVALID_PASSWORD_TYPE. A value of another type used to produce an unencrypted archive, and arawPasswordpassed as a string used to produce an archive that its equivalentpasswordcannot open. An unknownstrictnessorfilenameValidationthrows instead of behaving as"balanced". An invalidmaxAppendedDataSizethrows instead of being accepted. A non-integerencryptionStrength,uid,gidorunixModeis now rejected by the guard whose message already announced it. Values meaning "no password", i.e.undefined,null, an empty string and an emptyUint8Array, keep working as before. Numeric options also keep accepting the strings that represent them, e.g.levelset to"9", because form controls, query strings and environment variables all yield strings - The filesystem API now ignores empty and
.path components when importing an archive. Names such asa//b.txtand./cur.txtno longer create entries with an empty name or named. - When reading an entry fails, the
writableof the writer is now aborted with the error instead of being closed. A custom writer used to observe a successful close although the data was truncated
Bug fixes
- Errors raised by
addFileSystemHandle()andexportFileSystemHandle()are now rethrown unmodified instead of being wrapped. Theirmessageis comparable to the exportedERR_*constants again, and theirentryNameproperty identifies the handle or the entry that failed exportFileSystemHandle()called withconcurrentset totruenow cancels the entries that have not started yet when an entry fails, instead of letting the rest of the export run to completion
Build and packaging
- Web worker support is now tree-shakable. The web worker backend was moved to a separate module which registers itself when imported. Custom builds that do not import it no longer include the web worker plumbing and run codecs inline. The standard entry points import it, so the published builds are unaffected
- The most frequently used globals are destructured in the intro of the bundles, which reduces the size of the minified builds
Full Changelog: v2.8.49...v2.8.50