Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ module.exports = function (zipPath, opts, cb) {

var cancelled = false

zipfile.on('error', function (err) {
if (err) {
cancelled = true
return cb(err)
}
})
zipfile.readEntry()

zipfile.on('close', function () {
Expand Down
Binary file added test/broken.zip
Binary file not shown.
11 changes: 11 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var githubZip = path.join(__dirname, 'github.zip')
var subdirZip = path.join(__dirname, 'file-in-subdir-without-subdir-entry.zip')
var symlinkDestZip = path.join(__dirname, 'symlink-dest.zip')
var symlinkZip = path.join(__dirname, 'symlink.zip')
var brokenZip = path.join(__dirname, 'broken.zip')

var relativeTarget = './cats'

Expand Down Expand Up @@ -193,3 +194,13 @@ test('files in subdirs where the subdir does not have its own entry is extracted
})
})
})

test('extract broken zip', function (t) {
t.plan(2)

mkdtemp(t, 'broken-zip', function (dirPath) {
extract(brokenZip, {dir: dirPath}, function (err) {
t.ok(err, 'Error: invalid central directory file header signature: 0x2014b00')
})
})
})