Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw a more informative error if the file does not start with 0x50 0x4B 0x03 0x04 #182

Closed
SheetJSDev opened this issue Oct 17, 2014 · 0 comments · Fixed by #202
Closed
Labels

Comments

@SheetJSDev
Copy link
Contributor

$ cat test.txt
123
$ node -pe 'require("jszip")(require("fs").readFileSync("test.txt"))'

/usr/local/lib/node_modules/jszip/lib/zipEntries.js:135
            throw new Error("Corrupted zip : can't find end of central directo
                  ^
Error: Corrupted zip : can't find end of central directory
    at Object.ZipEntries.readEndOfCentral (/usr/local/lib/node_modules/jszip/lib/zipEntries.js:135:19)
    ....

If the file doesn't start with the correct magic number, JSZip should throw a different error (e.g. "Not a ZIP file")

@Stuk Stuk added the feature label Jan 7, 2015
dduponchel added a commit to dduponchel/jszip that referenced this issue Feb 18, 2015
Check if the content is a truncated zip or complete garbage.

A "LOCAL_FILE_HEADER" is not required at the beginning (auto extractible zip
for example) but it can give a good hint. If an ajax request was used without
responseType, we will also get unreadable data.

Fix Stuk#182.
@Stuk Stuk closed this as completed in #202 Feb 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants