From ba82ad4af376d45fdefeb16db1c76f59d9229e02 Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Tue, 31 Dec 2024 06:11:45 +0000 Subject: [PATCH] fix: correctly check bitflag for "streaming" zips --- lib/init.luau | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/init.luau b/lib/init.luau index cd4a0ef..1a27bd3 100644 --- a/lib/init.luau +++ b/lib/init.luau @@ -297,7 +297,8 @@ function ZipReader.extract(self: ZipReader, entry: ZipEntry, options: Extraction pos = pos + 30 + nameLength + extraLength - if bit32.band(bitflags, 0x08) then + if bit32.band(bitflags, 0x08) ~= 0 then + print("Unknown sizes, trying to find data descriptor") -- The bit at offset 3 was set, meaning we did not have the file sizes -- and CRC checksum at the time of the creation of the ZIP. Instead, they -- were appended after the compressed data chunks in a data descriptor @@ -338,6 +339,9 @@ function ZipReader.extract(self: ZipReader, entry: ZipEntry, options: Extraction uncompressedSize = buffer.readu32(self.data, descriptorPos + 12) end + -- print("Compressed:", compressedSize) + -- FIXME: while trying to extract contents of ZipTestData/refzipfiles/normal.zip, + -- the compressed size is TOO LARGE -- 3865074944 -- but zipinfo tells me otherwise local content = buffer.create(compressedSize) buffer.copy(content, 0, self.data, pos, compressedSize)