diff --git a/src/parse.ts b/src/parse.ts index d0b0781e..0147f786 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -199,6 +199,7 @@ export class Parser extends EE implements Warner { }) } else if ( !/^(Symbolic)?Link$/.test(type) && + !/^(Global)?ExtendedHeader$/.test(type) && header.linkpath ) { this.warn('TAR_ENTRY_INVALID', 'linkpath forbidden', { diff --git a/test/extract.js b/test/extract.js index 8fe8eff1..ce2afeb7 100644 --- a/test/extract.js +++ b/test/extract.js @@ -415,3 +415,17 @@ t.test('brotli', async t => { t.end() }) }) + +t.test('verify long linkname is not a problem', async t => { + // See: https://github.com/isaacs/node-tar/issues/312 + const file = path.resolve(__dirname, 'fixtures/long-linkname.tar') + t.test('sync', t => { + x({ sync: true, strict: true, file, C: t.testdir({}) }) + t.ok(fs.lstatSync(t.testdirName + '/test').isSymbolicLink()) + t.end() + }) + t.test('async', async t => { + await x({ file, C: t.testdir({}), strict: true }) + t.ok(fs.lstatSync(t.testdirName + '/test').isSymbolicLink()) + }) +}) diff --git a/test/fixtures/long-linkname.tar b/test/fixtures/long-linkname.tar new file mode 100644 index 00000000..34c0ea57 Binary files /dev/null and b/test/fixtures/long-linkname.tar differ diff --git a/test/unpack.js b/test/unpack.js index f7c4f88a..2f167a30 100644 --- a/test/unpack.js +++ b/test/unpack.js @@ -1821,11 +1821,12 @@ t.test('set owner', t => { if (!warned) { warned = true t.equal(er, poop) - t.end() } }, }) u.end(data) + t.equal(warned, true) + t.end() }) t.test('async', t => { @@ -1838,10 +1839,13 @@ t.test('set owner', t => { if (!warned) { warned = true t.equal(er, poop) - t.end() } }, }) + u.on('finish', () => { + t.equal(warned, true) + t.end() + }) u.end(data) })