Skip to content

Commit

Permalink
test using symlinks duh
Browse files Browse the repository at this point in the history
  • Loading branch information
mafintosh committed Jun 17, 2023
1 parent 71d681b commit 41af412
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 1 addition & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ exports.extract = function extract (cwd, opts) {
header.name = normalize(header.name)

const name = path.join(cwd, path.join('/', header.name))
console.log(header, name)

if (ignore(name, header)) {
stream.resume()
Expand Down Expand Up @@ -308,14 +307,11 @@ exports.extract = function extract (cwd, opts) {
}

function validate (fs, name, root, cb) {
console.log('validate', name, root)
if (name === root) return cb(null, true)
fs.lstat(name, function (err, st) {
if (err && err.code === 'ENOENT') return validate(fs, path.join(name, '..'), root, cb)
else if (err) return cb(err)
console.log('lookup', name)
if (st.isDirectory()) return cb(null, true)
cb(null, false)
cb(null, st.isDirectory())
})
}

Expand Down
8 changes: 7 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,13 @@ test('not finalizing the pack', function (t) {
}
})

test.solo('do not extract invalid tar', 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 Down

0 comments on commit 41af412

Please sign in to comment.