zip 1.7.1 → 1.7.2
raw patch · 4 files changed
+39/−21 lines, 4 filesdep ~resourcetdep ~textdep ~unix
Dependency ranges changed: resourcet, text, unix
Files
- CHANGELOG.md +5/−0
- Codec/Archive/Zip/Internal.hs +20/−14
- tests/Main.hs +10/−3
- zip.cabal +4/−4
CHANGELOG.md view
@@ -1,3 +1,8 @@+## Zip 1.7.2++* Now the ZIP64 extra field is only written when it is necessary. Previously+ it was written unconditionally and it confused some tools.+ ## Zip 1.7.1 * Fixed compilation with zstd and/or bzip2 disabled.
Codec/Archive/Zip/Internal.hs view
@@ -563,6 +563,8 @@ hSeek h AbsoluteSeek afterStreaming return (s, desc2) +{- ORMOLU_DISABLE -}+ -- | Create a 'Sink' to stream data there. Once streaming is finished, -- return 'DataDescriptor' for the streamed data. The action /does not/ -- close the given 'Handle'.@@ -612,6 +614,8 @@ ddUncompressedSize = uncompressedSize } +{- ORMOLU_ENABLE -}+ -- | Append central directory entries and the end of central directory -- record to the file that given 'Handle' is associated with. Note that this -- automatically writes Zip64 end of central directory record and Zip64 end@@ -774,12 +778,12 @@ Zip64ExtraField -> -- | Resulting representation ByteString-makeZip64ExtraField c Zip64ExtraField {..} = runPut $ do- when (c == LocalHeader || z64efUncompressedSize >= ffffffff) $+makeZip64ExtraField headerType Zip64ExtraField {..} = runPut $ do+ when (headerType == LocalHeader || z64efUncompressedSize >= ffffffff) $ putWord64le (fromIntegral z64efUncompressedSize) -- uncompressed size- when (c == LocalHeader || z64efCompressedSize >= ffffffff) $+ when (headerType == LocalHeader || z64efCompressedSize >= ffffffff) $ putWord64le (fromIntegral z64efCompressedSize) -- compressed size- when (c == CentralDirHeader && z64efOffset >= ffffffff) $+ when (headerType == CentralDirHeader && z64efOffset >= ffffffff) $ putWord64le (fromIntegral z64efOffset) -- offset of local file header -- | Create 'ByteString' representing an extra field.@@ -795,8 +799,8 @@ putCD m = forM_ (M.keys m) $ \s -> putHeader CentralDirHeader s (m ! s) --- | Create 'ByteString' representing a local file header if the first--- argument is 'False' and a central directory file header otherwise.+-- | Create 'ByteString' representing either a local file header or a+-- central directory file header. putHeader :: -- | Type of header to generate HeaderType ->@@ -805,11 +809,11 @@ -- | Description of entry EntryDescription -> Put-putHeader c' s EntryDescription {..} = do- let c = c' == CentralDirHeader- putWord32le (bool 0x04034b50 0x02014b50 c)+putHeader headerType s entry@EntryDescription {..} = do+ let isCentralDirHeader = headerType == CentralDirHeader+ putWord32le (bool 0x04034b50 0x02014b50 isCentralDirHeader) -- ↑ local/central file header signature- when c $+ when isCentralDirHeader $ putWord16le (fromVersion edVersionMadeBy) -- version made by putWord16le (fromVersion edVersionNeeded) -- version needed to extract let entryName = getEntryName s@@ -830,7 +834,7 @@ putWord16le (fromIntegral $ B.length rawName) -- file name length let zip64ef = makeZip64ExtraField- c'+ headerType Zip64ExtraField { z64efUncompressedSize = edUncompressedSize, z64efCompressedSize = edCompressedSize,@@ -838,9 +842,11 @@ } extraField = B.take 0xffff . runPut . putExtraField $- M.insert 1 zip64ef edExtraField+ if needsZip64 entry+ then M.insert 1 zip64ef edExtraField+ else edExtraField putWord16le (fromIntegral $ B.length extraField) -- extra field length- when c $ do+ when isCentralDirHeader $ do putWord16le (fromIntegral $ B.length comment) -- file comment length putWord16le 0 -- disk number start putWord16le 0 -- internal file attributes@@ -848,7 +854,7 @@ putWord32le (withSaturation edOffset) -- relative offset of local header putByteString rawName -- file name (variable size) putByteString extraField -- extra field (variable size)- when c (putByteString comment) -- file comment (variable size)+ when isCentralDirHeader (putByteString comment) -- file comment (variable size) -- | Create 'ByteString' representing Zip64 end of central directory record. putZip64ECD ::
tests/Main.hs view
@@ -84,6 +84,8 @@ instance Arbitrary ByteString where arbitrary = B.pack <$> listOf arbitrary +{- ORMOLU_DISABLE -}+ instance Arbitrary CompressionMethod where arbitrary = elements@@ -97,6 +99,8 @@ Deflate ] +{- ORMOLU_ENABLE -}+ instance Arbitrary UTCTime where arbitrary = UTCTime@@ -455,13 +459,16 @@ it "does not pass the check" $ \path -> property $ \b s -> not (B.null b) ==> do- let r = 50 + (B.length . T.encodeUtf8 . getEntryName $ s)- offset <- createArchive path $ do+ let headerLength = 30 + (B.length . T.encodeUtf8 . getEntryName $ s)+ localFileHeaderOffset <- createArchive path $ do addEntry Store b s commit fromIntegral . edOffset . (! s) <$> getEntries withFile path ReadWriteMode $ \h -> do- hSeek h AbsoluteSeek (offset + fromIntegral r)+ hSeek+ h+ AbsoluteSeek+ (localFileHeaderOffset + fromIntegral headerLength) byte <- B.map complement <$> B.hGet h 1 hSeek h RelativeSeek (-1) B.hPut h byte
zip.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.18 name: zip-version: 1.7.1+version: 1.7.2 license: BSD3 license-file: LICENSE.md maintainer: Mark Karpov <markkarpov92@gmail.com> author: Mark Karpov <markkarpov92@gmail.com>-tested-with: ghc ==8.8.4 ghc ==8.10.4 ghc ==9.0.1+tested-with: ghc ==8.8.4 ghc ==8.10.5 ghc ==9.0.1 homepage: https://github.com/mrkkrp/zip bug-reports: https://github.com/mrkkrp/zip/issues synopsis: Operations on zip archives@@ -67,7 +67,7 @@ mtl >=2.0 && <3.0, resourcet >=1.2 && <1.3, text >=0.2 && <1.3,- time >=1.4 && <1.10,+ time >=1.4 && <1.13, transformers >=0.4 && <0.6, transformers-base @@ -134,7 +134,7 @@ hspec >=2.0 && <3.0, temporary >=1.1 && <1.4, text >=0.2 && <1.3,- time >=1.4 && <1.10,+ time >=1.4 && <1.13, transformers >=0.4 && <0.6, zip