Stuk / jszip

Create, read and edit .zip files with Javascript
https://stuk.github.io/jszip/
Other
9.73k stars 1.3k forks source link

ZIP64 Support broken #922

Open tkrah opened 5 months ago

tkrah commented 5 months ago

I am trying to open a ZIP file which has zip64 support set but JSZip fails to handle that, while unzip or zipinfo and others are working:

Code:


"use strict";

var fs = require("fs");
var JSZip = require("jszip");

// read a zip file
fs.readFile("zip64-test.zip", function(err, data) {
    if (err) throw err;
        JSZip.loadAsync(data).then(function (zip) {

                    });
                    });

Output is:

/tmp/x/node_modules/jszip/lib/zipEntries.js:145
                throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length);
                      ^

Error: Corrupted zip or bug: expected 1 records in central dir, got 0
    at ZipEntries.readCentralDir (/tmp/x/node_modules/jszip/lib/zipEntries.js:145:23)
    at ZipEntries.load (/tmp/x/node_modules/jszip/lib/zipEntries.js:256:14)
    at /tmp/x/node_modules/jszip/lib/load.js:48:24

Other tools:

$ zipinfo -v zip64-test.zip 
Archive:  zip64-test.zip
There is no zipfile comment.

End-of-central-directory record:
-------------------------------

  Zip archive file size:                       270 (000000000000010Eh)
  Actual end-cent-dir record offset:           172 (00000000000000ACh)
  Expected end-cent-dir record offset:         172 (00000000000000ACh)
  (based on the length of the central directory and its expected offset)

  This zipfile constitutes the sole disk of a single-part archive; its
  central directory contains 1 entry.
  The central directory is 99 (0000000000000063h) bytes long,
  and its (expected) offset in bytes from the beginning of the zipfile
  is 73 (0000000000000049h).

Central directory entry #1:
---------------------------

  Test-üäöÜÄÖ.txt

  offset of local header from start of archive:   0
                                                  (0000000000000000h) bytes
  file system or operating system of origin:      MS-DOS, OS/2 or NT FAT
  version of encoding software:                   4.5
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   4.5
  compression method:                             deflated
  compression sub-type (deflation):               normal
  file security status:                           not encrypted
  extended local header:                          no
  file last modified on (DOS date/time):          2024 Mar 25 14:20:56
  32-bit CRC value (hex):                         00000000
  compressed size:                                2 bytes
  uncompressed size:                              0 bytes
  length of filename:                             21 characters
  length of extra field:                          32 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  non-MSDOS external file attributes:             000000 hex
  MS-DOS file attributes (00 hex):                none

  The central-directory extra field contains:
  - A subfield with ID 0x0001 (PKWARE 64-bit sizes) and 28 data bytes.  The first
    20 are:   00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00.

  There is no file comment.
$ unzip -l zip64-test.zip 
Archive:  zip64-test.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2024-03-25 14:20   Test-üäöÜÄÖ.txt
---------                     -------
        0                     1 file

zip64-test.zip

unilynx commented 4 months ago

Is jszip supposed to implement zip64 at all? I had a hard time finding a confirmation that it intends to do so

tkrah commented 4 months ago

Is jszip supposed to implement zip64 at all? I had a hard time finding a confirmation that it intends to do so

https://stuk.github.io/jszip/documentation/limitations.html according to this, imho yes.