Minor Changes
-
BREAKING CHANGE:
parseTarHeader(),parseTar(), andTarParsernow default topathPolicy: 'relative', throwingTarParseErrorfor empty entry names or link targets, absolute paths, Windows drive prefixes, backslashes, and embedded NULs. Entry names cannot contain..path components. Symlink targets are checked relative to the link's parent directory, and hard-link targets relative to the archive root;..components are allowed only when resolution stays within the archive. Valid paths retain their spelling, including nested paths,./prefixes, and trailing directory slashes. Applications that need to inspect or process unrestricted archive paths can opt intopathPolicy: 'preserve':-await parseTar(archive, handleEntry) +await parseTar(archive, { pathPolicy: 'preserve' }, handleEntry)
The same option works with
parseTarHeader()andnew TarParser(). It does not disable archive limits or header structure validation. Path validation applies after ustar prefixes and GNU/PAX overrides, before an entry reaches the handler. GNU long names and link targets now omit their terminating NUL under either policy. Extractors must still enforce containment on their destination filesystem, including when existing or archived symlinks are present. -
BREAKING CHANGE:
parseTar()andTarParsernow default to limits of 2 MiB per entry body, 20 MiB of total archive input, and 5,000 entries, where previously none were limited. Applications processing larger archives must configuremaxEntrySize,maxTotalSize, andmaxEntriesto raise the applicable limits, or set any limit toInfinityto disable it:-await parseTar(archive, handleEntry) +await parseTar( + archive, + { maxEntrySize: Infinity, maxTotalSize: Infinity, maxEntries: Infinity }, + handleEntry, +)
The entry size and count limits include PAX/GNU metadata entries and are checked before reading their bodies or invoking entry handlers. Padding and end markers do not count as entries. The total size limit counts all input bytes, including headers, padding, and metadata, after any upstream decompression. Exceeding a limit throws the exported
MaxEntrySizeExceededError,MaxTotalSizeExceededError, orMaxEntriesExceededError, all extendingTarParseError.Global PAX metadata now applies to subsequent entries even without a local PAX header, so global sizes are parsed and checked against the entry limit. Local PAX values continue to take precedence.
Patch Changes
-
Buffer
TarEntrycontent using the bytes received, validate octal, base-256, and PAX entry sizes, and reject unfinished body readers when archive parsing fails. -
Reduce allocation and copying when GNU or PAX metadata arrives in small chunks. Metadata buffering grows with the bytes received and continues to honor the configured archive limits.