Skip to content

Commit

Permalink
fix win (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
mafintosh authored Jun 17, 2023
1 parent 9076ed0 commit 6fa5d27
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ exports.extract = function extract (cwd, opts) {
function validate (fs, name, root, cb) {
if (name === root) return cb(null, true)
fs.lstat(name, function (err, st) {
if (err && err.code !== 'ENOENT') return cb(err)
if (err || st.isDirectory()) return validate(fs, path.join(name, '..'), root, cb)
cb(null, false)
if (err && err.code === 'ENOENT') return validate(fs, path.join(name, '..'), root, cb)
else if (err) return cb(err)
cb(null, st.isDirectory())
})
}

Expand Down
15 changes: 15 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ test('not finalizing the pack', function (t) {
})

test('do not extract invalid tar', function (t) {
if (win32) { // no symlink support on win32 currently. TODO: test if this can be enabled somehow
t.plan(1)
t.ok(true)
return
}

t.plan(2)

const a = path.join(__dirname, 'fixtures', 'invalid.tar')
Expand All @@ -310,9 +316,18 @@ test('do not extract invalid tar', function (t) {
t.ok(err)
})
})
.on('finish', function () {
t.fail('should not finish')
})
})

test('no abs hardlink targets', function (t) {
if (win32) { // no symlink support on win32 currently. TODO: test if this can be enabled somehow
t.plan(1)
t.ok(true)
return
}

t.plan(3)

const out = path.join(__dirname, 'fixtures', 'invalid')
Expand Down

0 comments on commit 6fa5d27

Please sign in to comment.