diff --git a/lib/unpack.js b/lib/unpack.js index a027ca02..29472a2a 100644 --- a/lib/unpack.js +++ b/lib/unpack.js @@ -209,6 +209,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 2c18ccc9..9874271b 100644 --- a/test/unpack.js +++ b/test/unpack.js @@ -191,16 +191,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() }