mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-05-14 03:01:48 +00:00
Support zstd inside zip files.
Given this is already depending on zstd I don't see a reason not to. Can be tested with libarchive via: `bsdtar -a --options zip:compression=zstd -cf file.zip files...` Reviewed-on: https://codeberg.org/git-pages/git-pages/pulls/91 Co-authored-by: David Leadbeater <dgl@dgl.cx> Co-committed-by: David Leadbeater <dgl@dgl.cx>
This commit is contained in:
committed by
Catherine
parent
62ef4a5366
commit
62917824fa
@@ -153,6 +153,9 @@ func ExtractTar(ctx context.Context, reader io.Reader, oldManifest *Manifest) (*
|
||||
return manifest, nil
|
||||
}
|
||||
|
||||
// Used for zstd decompression inside zip files, it is recommended to share this.
|
||||
var zstdDecomp = zstd.ZipDecompressor()
|
||||
|
||||
func ExtractZip(ctx context.Context, reader io.Reader, oldManifest *Manifest) (*Manifest, error) {
|
||||
data, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
@@ -164,6 +167,10 @@ func ExtractZip(ctx context.Context, reader io.Reader, oldManifest *Manifest) (*
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Support zstd compression inside zip files.
|
||||
archive.RegisterDecompressor(zstd.ZipMethodWinZip, zstdDecomp)
|
||||
archive.RegisterDecompressor(zstd.ZipMethodPKWare, zstdDecomp)
|
||||
|
||||
// Detect and defuse zipbombs.
|
||||
var totalSize uint64
|
||||
for _, file := range archive.File {
|
||||
|
||||
Reference in New Issue
Block a user