max-mapper / extract-zip

Zip extraction written in pure JavaScript. Extracts a zip into a directory.
BSD 2-Clause "Simplified" License
388 stars 126 forks source link

Add error handler to zipfile object #67

Closed matsnow closed 4 years ago

matsnow commented 6 years ago

@malept This PR adds the error handler to zipfile object before zipfile.readEntry called. The reason is It causes unhandled exception when extract broken zip (ex. Central Directory Entry has been broken).

events.js:137
      throw er; // Unhandled 'error' event
      ^

Error: invalid central directory file header signature: 0x2014b00
    at /Users/matsuo/develop/projects/extract-zip/node_modules/yauzl/index.js:231:70
    at /Users/matsuo/develop/projects/extract-zip/node_modules/yauzl/index.js:473:5
    at /Users/matsuo/develop/projects/extract-zip/node_modules/fd-slicer/index.js:32:7
    at FSReqWrap.wrapper [as oncomplete] (fs.js:676:17)

Currently, I use the forked library into my product, but more better is to apply this patch. Best regards!

malept commented 6 years ago

This seems reasonable but since this module is not my area of expertise (I'm here to merge and deploy security fixes), I would like at least one other person to review this.

matsnow commented 6 years ago

@malept Thanks for your reponse!

@maxogden
Would you mind reviewing this PR?

papb commented 4 years ago

It is great to see this merged! I probably no longer need this line of code