diff --git a/lib/unpack.js b/lib/unpack.js index 32950159..cf10d073 100644 --- a/lib/unpack.js +++ b/lib/unpack.js @@ -220,6 +220,8 @@ class Unpack extends Parser { const linkparts = normPath(entry.linkpath).split('/') if (linkparts.length >= this.strip) entry.linkpath = linkparts.slice(this.strip).join('/') + else + return false } } diff --git a/test/unpack.js b/test/unpack.js index e60915b9..3ebbb233 100644 --- a/test/unpack.js +++ b/test/unpack.js @@ -189,16 +189,8 @@ t.test('links!', t => { t.end() } const checkForStrip3 = t => { - t.ok(fs.lstatSync(dir + '/3').isDirectory()) - let err = null - try { - fs.lstatSync(dir + '/3/hardlink-3') - } catch (e) { - err = e - } - // can't be extracted because we've passed it in the tar - // (specially crafted tar for this not to work) - t.equal(err.code, 'ENOENT') + // strips the linkpath entirely, so the link doesn't get extracted. + t.throws(() => fs.lstatSync(dir + '/3'), { code: 'ENOENT' }) t.end() }