archive 4.6.0
archive: ^4.6.0 copied to clipboard
Provides encoders and decoders for various archive and compression formats such as zip, tar, bzip2, gzip, zlib, xz, and zstd.
4.6.0 #
- BREAKING CHANGE: All decoders (
XZDecoder,TarDecoder,ZipDecoder,GZipDecoder,ZLibDecoder,BZip2DecoderandZstdDecoder) and their wrappers likeextractFileToDisk,extractArchiveToDisk,extractArchiveToDiskSyncnow share the same contract: by default no damaged data errors are thrown anymore. If error is needed, specifythrowOnError: truetodecodeBytesordecodeStream. If checksum verification is required, specifyverify: truetodecodeBytesordecodeStream:throwOnErrordefaults toverify, so a mismatch or damage throws. Withverify: true, throwOnError: falseit is reported like no flags do,decodeStreamreturnsfalseanddecodeBytesreturns partial data. AllthrowOnErrorare reported asArchiveExceptionand checksum exceptions withArchiveChecksumExceptionthat extendsArchiveException.throwOnErroris nowbool?in these signatures, so a subclass that overrides them has to follow. Without flags, a damaged gzip or zlib stream from dart:io now decodes without an error, where 4.5.x threw because dart:io always checks the trailer. Errors such asRangeErrorfrom damaged data are reported the same way as other damage, where 4.5.x rethrew some of them asArchiveException. Read README for migration tips and exceptions that are still reported with original type (everything unrelated to damaged data and package code). - Unlike decoders mentioned above, all new converters APIs mentioned beneath use both
verifyandthrowOnErrorby default due to the specification of their format so that they completely coincide with dartzlibandgziptransformers. - BREAKING CHANGE: All decoders now properly handle
verify: trueparam and do not ignore it anymore.GZipDecoderandZLibDecoderthat rely on dart:io implementation still may not catch the checksum issue and report an error withthrowOnErrorfor some damaged archives: a gzip whose damaged data decodes longer than its declared size passes as a concatenated gzip, a checksum error inside a concatenated gzip is reported asArchiveException, and a truncated zlib stream is found only withverify, and thrown asArchiveException, as a truncated gzip is.GZipDecoderWebandZLibDecoderWebreport all of these. Cut raw deflate stream (raw: true) is not found by any flags there, it has no checksum. - BREAKING CHANGE: Added
writeRangeandreservetoOutputStream, andreadIntoandviewBytestoInputStream. All four have a default body, so a class that extends them needs no change. A class that implements them has to add these methods. - Fixed
extractFileToDiskdetecting files only by extension. It now also detects them by their header bytes as all platform decoders do (like MacOS, Windows, Linux). If detection by headers fails it uses old file extension format instead. - Fixed
ZipDecoderandextractFileToDiskthrowingExceptionfor an incorrect password, or returning wrong data for ZipCrypto. They now throwArchivePasswordExceptionthat extendsArchiveException. This exception overrulesthrowOnErrorand is thrown always when password does not match. AES MAC is checked now, a mismatch throwsArchiveMacExceptionthat extendsArchiveChecksumExceptionregardless of flags. extractArchiveToDiskandextractArchiveToDiskSyncthrow withArchivePasswordExceptionas well for bad password case.- Added
ArchiveLimitExceptionthat extendsArchiveException. It is thrown regardless ofverifyandthrowOnErrorwhen decoded data is larger thanmaxOutputSize, when extracted files are larger thanmaxSize, when a zstd window is larger thanmaxWindowSize, when an xz block declares a dictionary larger thanmaxDictionarySize, when a tar long name, PAX header or sparse map is larger thanTarFile.maxMetadataSize, and when a compressed zip entry decodes to more than its declared uncompressed size. - Fixed
listTarFilesandextractTarFilessilently using only the readable part of a damaged archive. They now throw an error for it. - BREAKING CHANGE:
lastModTimeof zip entries is now in seconds since epoch, as in tar, instead of the DOS date and time format. The DOS value it held before,date << 16 | time, is now inArchiveFile.lastModDosTime. - BREAKING CHANGE:
extractFileToDisknow acceptsverifyandthrowOnError,extractArchiveToDiskandextractArchiveToDiskSyncacceptthrowOnError. Without them a damaged or cut archive no longer throws: Complete entries are extracted, and damaged ones leave no partial files on disk. WiththrowOnErrorthe function throws an exception upon encountering the first corrupted entry, andverifyadds checksum checks to it. - BREAKING CHANGE:
CompressionTypehas new values,lzmaandxz, so a switch over it needs a case for each of them. - Fixed
TarEncoderwriting a tar hard link read byTarDecoderas a symlink, which pointed to a missing file. It now writes it back as a hard link. - Deprecated
AesDecrypt, use the exportedAesCtrinstead.AesDecryptis now a wrapper overAesCtrand gives the same output as before.Sha1,HmacSha1,pbkdf2HmacSha1andSha256are exported as well. - Fixed
ZstdDecoderthrowingArgumentErrorfor a malformed dictionary. It throwsZstdDictionaryException, which extendsArchiveException, since a dictionary can be damaged data as well as a wrong argument. - Fixed
ZstdEncoderthrowingArgumentErrorfor a level above 22 or belowzstdMinLevel. It clamps the level to that range, asZSTD_c_compressionLevelof libzstd does.zstdMinLevelis -131072 instead of -7, the value ofZSTD_minCLevel(). - Fixed
ZstdDecoderaccepting amaxWindowSizebelow 1024 bytes, the smallest zstd window. It throwsArgumentErrorfor it. - BREAKING CHANGE:
ArchiveFile.lastModDateTimereturns a localDateTimebuilt fromlastModTimein seconds since epoch, instead of a UTCDateTimebuilt from DOS date and time fields.ZipDecodertakes the time from the UT extra field (0x5455) when the entry has one, so a zip written byZipEncoderreads back the same time in every time zone. - Fixed
ZipDecoderreturning the content of the first of several entries with the same name with the metadata of the last one. It keeps the last one, as 3.x did. - BREAKING CHANGE:
extractFileToDiskcallscallbackfor a zip entry after the entry is written, as it does for tar. It used to call it for every zip entry while the central directory was read, before any file was written. - Fixed
extractFileToDiskextracting junk entries from a gzip, bzip2, xz or zstd file that does not hold a tar, also when its name ends with.tar.gzor a similar extension. It throwsArgumentErrorfor such a file. - Fixed
BZip2Decoderreturning only the first stream of concatenated bzip2 files, aspbzip2writes them, without an error. It decodes every stream in sequence, asbzip2 -ddoes. - Fixed
ZLibDecoderWebappending the streams after the first of concatenated zlib streams, matching dart:io of Dart 3.5.0, which was reverted as a bug. It decodes only the first and ignores the bytes after it, asZLibDecoderon dart:io does since Dart 3.5.2 (dart-lang/sdk#56481). extractArchiveToDiskwrites entries synchronously, asextractArchiveToDiskSyncdoes, and still returns aFuture.- Added
allowAbsoluteSymlinkstoextractFileToDisk,extractArchiveToDiskandextractArchiveToDiskSync. Absolute symbolic links are still skipped by default. - Extraction removes
\\?\,\\.\and\\?\UNC\prefixes, drive letters and leading slashes from entry names, as bsdtar does. An entry whose name is an absolute path used to be skipped. - Extraction skips an entry whose path runs through a symbolic link that is already in the output directory and points outside it, and keeps a symbolic link from the archive instead of turning it into a directory when a later entry has a path through it.
TarDecoderwithverifyandtarCodec.decoderthrow for a header whose size field is not a number.ZipEncoderwrites the CRC and sizes in the local header of a stored entry taken from another zip, which it used to write with a data descriptor (#421).- Added Dart async*
StreamTransformer/ByteConversionSink/Convertersupport (xzCodec,zstdCodec,bzip2Codec,tarCodecandzipCodec) for decode and encode (decoders for all formats except for zip). xz, zstd and bzip2 areConverters, bytes to bytes; tar and zip areStreamTransformers:TarDecoderTransformer,TarEncoderTransformerandZipEncoderTransformer. - Added
CodecsRecognizerwithArchiveFormatto recognize compressed file types with their header bytes. - Made CRC32, SHA-256, CRC64 and Adler32 significantly faster and less RAM-consumable on all
platforms (for
verify: true), and SHA-1 with its HMAC and PBKDF2 and AES for AES zip. - ZipCrypto decryption is 6.6-8.6x faster now: its keys are ints that stay exact on web instead of BigInt.
- Added
ProgressOutputStreamto monitor progress during unpack. - Added usage examples of new apis is package readme file, shrinked amount of docs for
XZDecoder. - Added
XZMultithreadOptions.converterandZstdMultithreadOptions.converter, the options aConvertertakes for multithreaded decoding/encoding via converter. - Added
ultratoZstdEncoderConverterandZstdCodec. WithoutcontentSizelevels 20-22 are reduced to 19 unlessultra: trueis given, aszstddoes without--ultra: level 22 of unknown size takes 655 MB even for 100 bytes of input.ZstdEncoderknows the input size and takes these levels without the flag. - CRC64 for XZDecoder now works both on io and web (dart2-js) (with new
Crc64class). Old apiisCrc64Supportedremained unchanged and still returns false and throws withgetCrc64on dart2-js. - Significantly reduced XZDecoder RAM usage for --x86, crc32, crc64, SHA-256 and default decoding with
decodeStream. - Reduced RAM usage used by
GZipDecoder.decodeBytesandZLibDecoder.decodeByteson dart:io - Slightly reduced amount of used RAM by
ZLibDecoder. - Added
blockSize100ktoBZip2Encoder.encodeBytesandencodeStream - Added
ArchiveFile.isHardLink, set byTarDecoderfor tar hard links.symbolicLinkis unchanged. - Fixed symlinks scopes for
extractFileToDiskthat could overwrite existing file on disk outside of output dir - Fixed Unix mode reading for
ZipDecoderfor archives created on Windows. - Fixed
ZipDecoderreading a zip entry name that is not valid UTF-8 as Latin-1. It reads it as CP437, the encoding zip tools use when the UTF-8 flag is not set, so such names list differently than in 4.5.1. PassZipDecoder(filenameEncoding:)to read them in another encoding. - Fixed
ZipDecoderignoring the Info-ZIP Unicode Path extra field (0x7075). An entry that has one lists under the UTF-8 name from that field, so names differ from 4.5.1. The field is used only when its CRC matches the stored name. - Fixed CRC64
XZEncoderfiles created on dart-js failed to decode on native platforms. - Fixed
ZLibDecoderon web. TarEncodernow writes"ustar\0"magic in header for easier recognition.TarEncodernow writes non-ASCII names and symlink targets as PAX path/linkpath records, so readers that take header bytes in a local code page, such as Windows tar.exe, get the right names.- Zip passwords are now encoded as UTF-8 to properly handle non-ASCII passwords.
ZipDecodertries UTF-8 first and then bytes that older versions of the package wrote. - Fixed
ZipDecoderdecrypting AES and ZipCrypto entries inside the buffer, what corrupted it. - Fixed(added) LZMA decoding for
ZipDecoderand encoding forZipEncoderwithCompressionType.lzma. Encoder still falls back to DEFLATE, but decoder properly reads lzma data. ZipDecodernow reads zstd (method 93) and xz (method 95) zip entries asCompressionType.zstdandCompressionType.xz, andZipEncoderwrites them withZstdEncoderandXZEncoder.XZEncoderstores data uncompressed, so an xz entry is not smaller than its data.TarDecoderandtarCodec.decodernow read sparse files the way libarchive does: old GNU sparse headers with extension blocks and PAX sparse formats 0.0, 0.1 and 1.0. Holes are expanded when the content is read.- Fixed
mode0 file rights forArchiveFilefromZipDecodercreated on Windows. - Fixed SHA-256 checks for XZDecoder with
verify: true. - Fixed symlinks encoding in
ZipEncoderand decoding non-ASCII names with macos unzip from archives of this package. - Fixed latin1 encoding for
TarEncoderwith non-ASCII file names. - Fixed
ArchiveFile.directorymode (0755 instead of 0644) so that it can be opened after unpacking. - Fixed a few cases with accepting corrupted file in
XZDecoder. - Fixed some 7z files failed to decode with
XZDecoder. - Fixed invalid bzip2 archive returned true from
decodeStream. - Fixed
BZip2DecoderthrowingRangeErroron an archive cut inside a block when it read from anInputMemoryStream. Both memory and file streams return false now, without inconsistency. - Fixed a zip entry compressed with bzip2 handing back short data with no error when the entry is
damaged. It throws
ArchiveExceptionnow, the way a damaged deflate entry already did. - Fixed file names trimming in TAR.
ZipEncodernow applies CompressionType.none to entries with no content.- Replaced
ChunkedConversionSinkwithZLibOutputSinkfor gzip and zlib to forward every piece the codec produces instead of holding it to the end. - Fixed tar stream decoder allocating whatever a GNU long name or PAX header declared, before any of those bytes arrived. A 512 byte header claiming 2^40 was an out of memory kill; the buffer now grows with what actually arrives.
- Fixed
ZipEncoderwith a password writing a stale MAC into entries that have no content, such as every directory. The local header declared 12 bytes it never wrote, which left every local header after it off by 2 and unreachable to a forward-only reader. - Added
ZipEncoder(streamed: true)that writes entries as they are read, with low RAM usage on big files (4GB+, uses zip64 format from zip APPNOTE). - Fixed decoding zip64 with
ZipDecoder. - Multithreaded
XZDecoder.decodeStreamnow stops at the first broken block, like the single threaded one. - Fixed
ZipDecoderreturning an empty archive for a zip with extra bytes in front of it (self extracting zips). - Fixed
ZipDecoderthrowingRangeErrorinstead ofArchiveExceptionfor some damaged zips. - Fixed
LzmaDecoderthrowingRangeErrorfor truncated or damaged LZMA data, andXZDecoderreading more bytes than the input has for a stream cut inside a stream header, block header, LZMA2 chunk header, index or footer. They throwArchiveExceptionand report a truncated stream. LzmaDecoderstops at the end marker of an LZMA stream of unknown size, as NSIS installers store them, instead of failing.endMarkerSeentells whether it did.XZDecoderrejects an LZMA2 chunk that has one, which LZMA2 does not allow.- With
verify, a wrong CRC in an xz stream header, block header, index or footer, and a wrong gzip header checksum (FHCRC), throwArchiveChecksumExceptioninstead ofArchiveException.GZipDecoderWebchecks the header checksum. - Fixed
TarDecoderadding garbage folders to names in archives made by GNU tar--incremental. - Fixed
TarDecodertreating some folder entries (GNU and very old tar formats) as files. - Fixed
TarDecoderlong names in archives made by older versions of this package. - Fixed
BZip2Decoderrejecting some valid archives and data after the end of an archive, same as bzip2 1.0.8. - Fixed
XZDecoderfailing on archives larger than 4 GB on the web. - Fixed
InputFileStream.toUint8ListandreadBytesreturning wrong bytes when a file is read in parts. GZipDecoderWebandZLibDecoderWebare ~60x faster when writing to a file now.- Fixed
ZipEncoderemptyingArchiveFile.streamentries, so they could not be read after encoding. - Fixed
ZipEncoderwith a password changing the original data of entries in memory. - Fixed
extractFileToDisknever returning when the output drive does not exist. - Fixed multithreaded
XZDecoderhanging on a truncated file and accepting some damaged archives that single threaded decoding refused. - Fixed
BZip2Decodercrashing on an archive that declares block size 0. - Fixed
ZipDecoderwithverify: truerejecting AES zips that store no CRC. - Fixed
ZipEncoderwriting a wrong CRC when encoding again an archive decoded from an AES zip - Fixed a stored zip entry reading back empty after it was written to a file.
ArchiveFile.streamnow takes the stream from its current position instead of from the start.- Fixed
ZipEncoderfailing to create on the web. TarDecoderwithverify: truenow reports a file that is cut short, like other tar tools do.- Fixed
ZipEncoderzip64 for small files that follow large ones and for entries over 4 GB. - Fixed
InputFileStreamignoring itsbyteOrderforreadUint16,readUint24,readUint32andreadUint64. - Fixed
ZLibDecoderWebandGZipDecoderWebdepending on the byte order of the input stream:decodeStreamfailedverifyon a whole zlib stream from a little-endian stream, and gzip failed on a big-endian one. - Fixed not-restoring original InputStream endian for some decoders and encoders and decoding/encoding BigEndian files.
- Fixed
ZLibDecoderWebdropping the decoded data when bytes follow the stream, and accepting an empty input. - Fixed
ZipDecoderreturning the raw compressed bytes as the content of an entry with an unsupported compression method. WiththrowOnErrororverifyreading that entry throwsArchiveException, without them it is empty, andextractFileToDiskskips it and extracts the rest. - Fixed an empty zip password encrypting and decrypting entries with an empty key.
- Fixed ZipDecoder allocating size of a deflate entry over 500 MB, which threw
OutOfMemoryErrorfor a zip64 entry that claims terabytes. - Fixed
listTarFileslisting a plain .tar as empty, andlistTarFilesandextractTarFilesleaving open files and temporary folders uncleaned. - Fixed
ZLibDecoderWebandGZipDecoderWebaccepting malformed deflate: a zlib header with a method other than deflate or a window over 32 KB, a stream without its final block, and an oversubscribed Huffman table, which decoded to garbage before, are now reported withthrowOnErrorandverify. - Fixed
ZipFileEncoder.storewriting entries as deflate level 0 and holding each whole entry in memory: a 1 GB file needed 2 GB of RAM. Thestorelevel ofcreate,zipDirectory,addFile,addFileSyncandaddDirectorynow writes uncompressed entries (method 0) streamed from the file. AnArchiveFilegiven toaddArchiveFileis stored too, unless itscompressionis set. - Fixed
ZipFileEncoderholding each whole deflated entry in memory: a 920 MB file needed 1042 MB of RAM at level 1 and 667 MB at level 6, now 19 MB at every level.ZipFileEncodernow usesZipEncoder(streamed: true), so a deflated entry without a password has bit 3 set, zero CRC and sizes in its local header, and a data descriptor after its data. The archives decode the same, but their bytes differ from earlier versions. - Fixed
OutputFileStream.writeStreammoving the read position of its source to the end, unlike the otherOutputStreamtypes. The source position is now left unchanged. ZipDirectory.readno longer reads every entry's local header. AZipFileHeaderreads itsfilewhen it is first asked for, and leaves the stream where it was.ZipDecoderreads each entry'sfileas before. Code that usesZipDirectorydirectly has to keep the stream open until it has readfile, and gets an error in a local header fromfileinstead of fromread.- Added
ZipDirectory.headers, which reads the central directory one entry at a time as it is iterated, so a caller that walks a large archive holds one header at a time.ZipDirectory.readcollects it intofileHeadersas before. Withfiles: falsethe headers keep no reference to the stream, for a caller that reads entries itself.
4.5.2 #
- Fixed
ZipDecoder.decodeStreamreturning an empty archive when the input was not at position 0, such as after reading a magic number or decoding the same stream a second time (#405).decodeStreamalso leaves the input's read position where it was. - Added
InputStream.totalLength, the size of the whole stream whatever the read position, wherelengthis only the bytes after it.
4.5.1 #
- Fixed zips written on the web, which decoded to nothing: the zlib encoder left the zip encoder's output big-endian, so every header after the first entry's data was written in the wrong byte order (#419).
ZipEncodercan be used under dart2js on Node, where creating its secure random source threw; it is now only created for a password.- Fixed zips written by
ZipEncodersince 4.4.0, which 7-Zip reported as having header errors: the data descriptor flag was set in each entry's local header but not its central directory header. The UTF-8 flag also went into the central directory even for names that were not UTF-8. - Directory entries are stored rather than written as an empty deflate
stream, which
unziprejected, and carry the MS-DOS directory attribute. In a zip with a password they are no longer marked encrypted. - Entries whose content is in memory, and stored entries that can be read
twice, have their CRC and sizes in the local header again rather than in
a data descriptor after the data. Java's
ZipInputStreamrefuses a stored entry with a descriptor, and OpenDocument and EPUB files need their storedmimetypeentry without one (#421).
4.5.0 #
- Security:
XZDecoderhung forever on a truncated.xzread from a file or a decode stream, including.tar.xzinextractFileToDisk. - Security: tar long name and pax header entries are limited to
TarFile.maxMetadataSize(1 MB). A small.tar.gzcould declare one large enough to take gigabytes of memory to read. - Security: decoding had no output limit, so a small archive could expand
to fill memory or disk. Added
maxOutputSizetodecodeBytesanddecodeStreamonGZipDecoder,ZLibDecoder,BZip2DecoderandZstdDecoder, andmaxSizetoextractFileToDisk,extractArchiveToDiskandextractArchiveToDiskSync. - A zip entry is no longer decoded past the uncompressed size the archive
gives for it, so
ArchiveFile.sizecan be checked before reading. - Security:
ZstdDecodersized its window and output from the frame header, so a 10 byte input committed hundreds of MB, even pastmaxWindowSize. The content size is now checked as each block decodes, and one that overflows is refused. - Security:
XZDecoderlimits the LZMA2 dictionary an archive may declare tomaxDictionarySize(256 MB by default), which bounds the memory a streaming decode takes. It also takesmaxOutputSize, and no longer preallocates gigabytes because a tiny archive's index claims them. - Multithreaded xz decoding checks each block against the size the index gives it. An index that misstated one used to make the ordered output hold everything after it in memory and report success with the output cut short. Blocks are no longer let run far ahead of the output.
- Security: extraction creates symbolic links after every other entry and refuses one whose path runs through another link. A chain of links that each looked safe on its own could place a file outside the output directory.
- Security:
extractTarFilesdid not keep entries inside the output directory. It now extracts asextractFileToDiskdoes, decoding as it reads rather than through a temp file it left behind. - Extraction reports an entry that fails to decode instead of leaving a partial file without a word, and an empty file no longer takes a 1 MB write buffer.
- A tar hard link, which is extracted as a symbolic link, now points at its target from the link's own directory.
TarDecoder.decodeStreamanddecodeBytestakekeepEntries. False passes entries only to the callback, so memory no longer grows with the entry count;extractFileToDiskuses it. A.tar.gzof a million empty entries now decodes in 39 MB rather than 326 MB.- Malformed zip headers, such as an odd length extra field on an encrypted
entry or a zip64 locator pointing past the file, threw
RangeErrorinstead ofArchiveException. The AES extra field is also found when other extra fields come before it. BZip2Decoderaccepts a block declaring more than 18002 selectors and ignores the extra ones, as libbzip2 does, instead of reporting a truncated stream.- Reading a zip entry no longer preallocates its declared size when the compressed data could not expand that far.
4.4.0 #
- Security: a crafted zip64 compressed size overflowed the stream bounds checks and could crash the decoder while reading an untrusted archive. Sizes are now clamped to the bytes actually present.
- Added
InputDecodeStreamanddecodeLazyonGZipDecoder,ZLibDecoder,BZip2Decoder,ZstdDecoderandXZDecoder, which decode a stream as it is read so a large archive can be piped into another decoder without a temp file. extractFileToDiskextracts.tar.gz,.tar.bz2,.tar.xzand.tar.zstin a single pass, writing each entry as it is reached, with no temp file.- Decoding and encoding no longer buffer the whole file: gzip and zlib
streaming,
ZipEncoder, and encrypted zip entries (ZipCrypto and AES) now work in a bounded amount of memory whatever the file size. - Encrypted zip entries are decrypted as they are read; a wrong password now surfaces when the content is read.
- Faster decoding:
getCrc32is about three times quicker on typed data, andInputFileStreamreads in larger blocks. - Fixed
XZEncoder, which produced archives other tools rejected for inputs of 128 bytes or more.
4.3.0 #
- Added
ZstdDecoder, a pure Dart decoder for the zstd (Zstandard) format. - Added
ZstdEncoder, a pure Dart zstd encoder for the VM, JavaScript and wasm, at levels -7 to 22. - Zip entries compressed with zstd.
extractFileToDiskand the tar command accept.tar.zstand.tzst, andTarFileEncoder.tarDirectorycan write.tar.zstwithcompression: TarFileEncoder.zstd.- Added multithreaded decoding to XZDecoder. Passing an
XZMultithreadOptionstodecodeBytesordecodeStreamspreads the work over isolates, one xz block per job, and reports the result through itsonDonecallback. Both methods behave exactly as before when it is omitted. On a 1.1 GB archive of six blocks: 16.1 s single threaded, 8.0 s on the default three workers, 5.0 s on six. decodeStreamreading from anInputFileStreamnow lets each worker read its own block straight from disk, so the compressed archive never passes through the calling isolate. Decoding a 1.1 GB archive to anOutputFileStreampeaks at 1.8 GB, below the 3.0 GB the single threaded path uses, while being twice as fast.- Multithreaded decoding falls back to the single threaded path on the web, where there are no isolates, and the isolate machinery is tree-shaken out of web builds entirely.
- Added
InputFileStream.fileBuffer,fileOffsetandfileLength. - Added
--x86flag support to XZDecoder - Improved verify: true speed for XZDecoder
- Improved overall decode speed for XZDecoder
- Decreased RAM usage for XZDecoder
- Added concatenated streams support for XZDecoder
- Added crc64 wasm support (
verify: true) - Added
uncompressedSizegetter for XZDecoder, returning the original file size before compression. - Fix: pb=4 flag range error in XZDecoder
- Fix: padding for _streamStart in XZDecoder
- Added
throwOnErrortoXZDecoder.decodeBytesanddecodeStream. Without it a malformed or truncated archive still returns the partial output with nothing to say it is not the whole file, which was the only decode with no way at all to report a failure. In multithreaded mode the exception is delivered toXZMultithreadOptions.onError, and settingthrowOnErrorwithout anonErroris now refused rather than losing the failure. - Fix: a corrupt xz block lost the part of itself that had already decoded when
verify: truewas used with an output that cannot be read back, such as anOutputFileStreamor any multithreaded decode. The output now stops in the same place whichever way the decode was asked for. - Added
XZDecoder.maxPreallocateSize, capping how large an output buffer is allocated from a size the archive itself declares. Defaults toxzDefaultMaxPreallocateSize, 2 GB natively and 256 MB on the web. - Added
XZMultithreadOptions.fileReadBufferSize. - Fix: an
xz --check=nonearchive with corrupt blocks passedverify: true. - Fix: the xz block header reader trusted its own fields, accepting an unterminated multibyte integer, a filter properties length past the end of the header, empty delta or LZMA2 properties, and a bad stream header or footer CRC.
- Fix: the zip End of Central Directory record was missed when its signature straddled a chunk of the backwards search, or sat within the last 21 bytes of the file, so a valid archive could decode as empty.
TarDecoderwithverify: truenow checks each header's own checksum and throwsArchiveExceptionon a mismatch.- Fix: GNU base-256 numeric tar header fields were read as octal, so sizes of 8 GB or more and large uid, gid and mtime values decoded as garbage.
- Fix: tar PAX extended headers are walked by each record's declared length instead of split on newlines, so a record holding binary no longer corrupts the rest of the header.
- Fix: a PAX
sizerecord was applied to the metadata headers following it rather than to the entry it describes. - Fix: a GNU
././@LongLinkheader of typeKset the next entry's name instead of its symlink target. - Fix:
storeData: falseskipped the tar long name and PAX headers along with the file data, losing the names they carry. - Fix: a negative size in a tar header is refused instead of read as an entry.
- Fix: with
verify: truethe end of a tar is a full 512 byte zero block, which two zero bytes could not be told apart from a damaged header. A tail shorter than a header block now ends the archive instead of decoding as junk. - Fix: tar base-256 fields wider than
TarFile.maxNumericFieldare refused on read and write instead of overflowing silently. - Fix: decoded regular tar files were given an empty link name and re-encoded as symlinks.
- Fix: long tar names and symlink targets were written without the
LandKtype flags, so other tar implementations truncated them to 100 bytes, and long symlink targets were not written at all. - Fix: the GNU long name record was sized in characters rather than encoded
bytes and ignored
filenameEncoding. - Fix: encoding a tar entry consumed the stream it was given, so a second encode of the same archive wrote empty entries.
- Fix: tar values too wide for the octal header field are written in GNU base-256 form instead of producing a corrupt header.
TarEncodercopies a stored stream through in chunks rather than reading the whole entry into memory.TarFile.contentis now settable and reads back what was set.- Fix:
GZipDecoder.decodeStreamreturned true for a truncated or corrupt archive, silently losing files. - Fix: the web gzip decoder never checked the member CRC32 despite
verify: true. - Fix: the web gzip header reader trusted its own length fields, reading past the end on a damaged extra field, an unterminated name or comment, or a header under ten bytes.
- Fix: a gzip input under 20 bytes had header bytes read as a trailer.
- The native gzip decoder now reads in 8 KB chunks instead of 1 KB.
- Fix: an incomplete Huffman code table entry consumed no bits and looped forever, and a code length repeat past the end of the table indexed out of range.
- Fix: an Inflate back-reference distance reaching past everything written indexed behind the output buffer.
- Fix: the web zlib decoder read its two byte header without checking two bytes were there.
- Fix: a short read near the end of a file overwrote the buffer's size with the bytes read, so every later read missed the cache and went back to disk.
- Fix: multi-byte
FileBufferreads refilled the cache one byte early, costing a re-read on every buffer-aligned access. - Fix:
InputFileStream.subsetdid not clamp its length to what remains of the source, so peeking past the end returned stale bytes. - Deprecated the
fileSizeparameter of theFileBufferread methods, which is ignored.
4.2.0 #
- Optimize performance and issues with large files with XZDecoder.
4.1.0 #
- Fix: RangeError when parsing ZIP extra fields with trailing bytes.
- Optimize LZ77 decode
- Fix: issue with file_buffer preventing last value
- Fix: invalid path separator in zip content compression
4.0.9 #
-
Fix extractFileToDisk file extension handling, where foo.bar.zip would fail.
4.0.8 #
- Remove dependency to crypto package
- Removed Adler32 and Crc32 classes
- Fix: extractArchiveToDisk extensions should be case insensitive.
- Fix: extractFileToDisk for .tar.gz files
- Add ZipFileEncoder.addDirectorySync
- Always use posix separators for ZipFileEncoder
4.0.7 #
- Change posix dependency to 6.0.2.
4.0.6 #
- Fix zip decoding when the last file of the archive is also a zip.
- Add lastModifiedDateTime to ArchiveFile
- Fix Archive files and fileMap getting out of sync after calling removeFile
4.0.5 #
- Improve performance of OutputFileStream.
- Add ArchiveFile.noCompress, which had been removed from the 3.x to 4.x update.
- GZipDecoder should fall back to ZLib if there is no GZip header.
4.0.4 #
- Fix level argument for ZipEncoder.add method.
- Fix ArchiveFile.compression to work for controlling compression method used encoding zips.
- Add ArchiveFile.compression CompressionType.bzip2 compression mode support.
- Add ArchiveFile.compressionLevel to work for controlling compression level used for encoding zips.
4.0.3 #
- Fix potential infinite loop when parsing zip headers.
- Update conditional imports to be compatible with WASM.
- Add addFileSync to ZipFileEncoder for synchronous call to addFile.
4.0.2 #
- Reduce SDK min version to 3.0.
- Fix import error with js_interop.
4.0.1 #
- Fix error with GZip encoder for web builds.
4.0.0 #
- Major cleanup of the code, includes potential breaking changes.
- decodeBuffer has been renamed to decodeStream in the various decoder classes.
- InputStream has been renamed to InputMemoryStream.
- OutputStream has been renamed to OutputMemoryStream.
3.6.1 #
- Fix ArchiveFile.rawContent returning null after decoding a zip.
3.6.0 #
- Fix zip encoding when a file was previously decoded.
- Fix decoding zips with password when using InputFileStream.
- ZipEncoder.encode autoClose now defaults to false.
3.5.1 #
- Re-add zipPath to ZipFileEncoder.
3.5.0 #
- Remove dependency to pointycastle package
- Use utf8 encoding for string data
- Fixes for encrypted zip encoding
- Async and sync versions of extractArchiveToDisk
3.4.10 #
- Fix ZipCrypto decryption
3.4.9 #
- Revert breaking change for extractArchiveToDisk becoming async; add extractArchiveToDiskAsync for the async version.
3.4.8 #
- Improve zip decompression performance with dart:io by using native ZLib decompression when possible.
3.4.7 #
- Improve performance by not using List.setRange for copying bytes, which turns out to be very slow.
3.4.6 #
- Fix for Zip64 file size causing memory errors.
3.4.5 #
- Rewrote InputFileStream to reduce overall memory by using a shared file cache.
- Added
DateTime lastModDateTimegetter to ArchiveFile. - Add support for zip encryption.
3.4.4 #
- Fix for new default buffer size for InputFileStream consuming too much memory for large archives.
3.4.3 #
- Fix bug in InputFileStream that caused it to only have an 8-byte buffer, making file streaming slow.
- Increase the default buffer size for file I/O streams to 1MB.
- Update pubspec dependency versions.
3.4.2 #
- Add bzip2 decompression for zip files.
3.4.1 #
- Fix for decoding zip64 zip files that have multiple extra fields.
3.4.0 #
- Add Zip64 support to ZipEncoder to allow it to create zip files > 4GB.
3.3.9 #
- Fix for extractFileToDisk causing corrupt files by closing a file stream before it finished writing.
3.3.8 #
- Fix for zip security issue with symlinks, https://github.com/brendan-duncan/archive/issues/265. https://osv.dev/vulnerability/GHSA-9v85-q87q-g4vg.
- Fix for zip security issue with file paths, https://github.com/brendan-duncan/archive/issues/266. https://osv.dev/vulnerability/GHSA-r285-q736-9v95.
- Add progress callback for decoding zip files.
- Don't allow tar files to include absolute paths.
- Fix error decoding AES-192.
3.3.7 #
- Add Zip AES-256 decryption
- Fix symlink encoding for tar files
3.3.6 #
- Fix errors decoding XZ files.
3.3.5 #
- Fix file content when decoding zips
3.3.4 #
- Fix analysis errors.
3.3.3 #
- Support symlinks in ZIP archives
- Fix ZIP decryption for ZipCrypto format
3.3.2 #
- Fix for UTF-8 file name caused problem on Windows.
3.3.1 #
- Fix for Inflate crashing on some compressed files.
3.3.0 #
- IO encoders (ZipFileEncoder, TarFileEncoder), will now include directories and empty directories.
- Fix for ZipEncoder file lastModTime.
- Fix for ArchiveFile.string.
- Add PAX format to tar decoder.
- Make more file operations async.
3.2.2 #
- Re-add List
- Add String and TypedData (Int32List, Float32List, etc) content data for ArchiveFile.
3.2.1 #
- Added buffer to OutputFileStream to improve performance by reducing the number of file writes.
3.2.0 #
- For non-web applications, use native 'inflate' decompression when decompressing zip files.
- Add asyncWrite option to extractArchiveToDisk and extractFileToDisk, moving file write operations to be async.
- ArchiveFile.writeContent will release its memory after the data has been written, reducing overall memory usage.
- Add clear method to ArchiveFile, clearing any decompressed data memory it's storing.
3.1.11 #
- Fix indexing bug in Archive.addFile.
3.1.10 #
- Fix performance regression with Archive.
3.1.9 #
- Fix FileInputStream to work with ZipDecoder.
3.1.8 #
- Catch invalid UTF8 string decoding.
3.1.7 #
- Fix for UTF8 filenames
3.1.6 #
- Fix problem with non-terminating long filenames.
- File modification dates were incorrectly stored in milliseconds instead of seconds.
3.1.5 #
- Disable XZ format CRC64 for html builds to fix errors.
3.1.4 #
- Changed LICENSE to MIT.
3.1.3 #
- Cleaned up LICENSE, moving other licenses to LICENSE-other.md.
3.1.2 #
- Added the ability to override the timestamp encoded in a Zip file.
3.1.1 #
- Fix zip encoder so that zip files created on Windows will open correctly on Linux.
3.1.0-dev #
- Added
constconstructors toZLibDecoder,ZLibEncoder, andZLibDecoderBase.
3.0.0 #
- Stable release supporting null safety.
3.0.0-nullsafety.0 #
- Migrate to null safety.
2.0.13 #
- Switch to dart strong mode; refactor code to resolve all dartanalyzer warnings.
2.0.12 #
- Fix dartanalyzer warnings
2.0.11 #
- Set the default permission for ArchiveFile to something more reasonable (0644 -rw-r--r--)
2.0.10 #
- Fix for decoding empty zip files.
2.0.9 #
- Add isSymbolicLink and nameOfLinkedFile to ArchiveFile.
- Fix for encoding empty files.
2.0.8 #
- Fix zip isFile
2.0.7 #
- Fix zip file attributes.
2.0.6 #
- Support GNU tar long file names
- Maintain unix file permissions in zip archives.
2.0.5 #
- Use dart:io ZLibCodec when run from dart:io.
2.0.4 #
- Fix InputStream when a Uint8ListView is used as input data.
2.0.3 #
- Use Utf8 for reading strings in archive archive files, for filenames and comments.
2.0.2 #
- Fixes for ZipFileEncoder.
2.0.1 #
- Remove the use of
partandpart ofin the main library. - Added ZipFileEncoder to encode files and directories using dart:io.
- Added createArchiveFromDirectory function to create an Archive object from a dart:io Directory.
2.0.0 #
- Moved version up for Dart 2 support.
- Fixed an issue with file compression flags when decoding zip archives.
- Fixed an issue with bzip2 decoding in production code.
1.0.33 #
- Support the latest version of
package:args.
1.0.30 #
- Add archive_io sub-package for supporting file streaming rather than storing everything in memory. This is a work-in-progress and under development.
1.0.29 #
- Fix issue with POSIX tar files.
- Upgrade dependency on
archiveto>=1.0.0 <2.0.0
1.0.20 #
- Improve performance decompressing large files in zip archives.
1.0.19 #
- Disable CRC verification by default when decoding archives.
1.0.18 #
- Add support for encoding uncompressed files in zip archives.
1.0.17 #
- Fix a bug in InputStream.
1.0.16 #
- Add stream support to Inflate decompression.
1.0.15 #
- Improved performance when writing large blocks.
1.0.14 #
- Misc updates and fixes.
1.0.13 #
-
Added BZip2 encoder.
-
BREAKING CHANGE:
Filewas renamed toArchiveFile, to avoid conflicts withdart:io.
1.0.12 #
- Added BZip2 decoder.
1.0.11 #
- Changed
InputStreamto work with typed_data instead ofList<int>, should reduce memory and increase performance.
1.0.10 #
-
Renamed
InputBufferandOutputBuffertoInputStreamandOutputStream, respectively. -
Added
readBitsmethod toInputStream.