From 46f1c6ad4b2fd5b0d7ec879b76b76a70a3a2595c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Tue, 7 Aug 2018 13:07:03 -0700 Subject: [PATCH] tar@4.4.6 Fixes: https://github.com/npm/node-tar/issues/177 Credit: @isaacs --- node_modules/tar/README.md | 3 +++ node_modules/tar/lib/header.js | 22 +++++++++++++++++++--- node_modules/tar/lib/parse.js | 2 +- node_modules/tar/lib/unpack.js | 8 ++++++-- node_modules/tar/package.json | 22 +++++++++++----------- package-lock.json | 6 +++--- package.json | 2 +- 7 files changed, 44 insertions(+), 21 deletions(-) diff --git a/node_modules/tar/README.md b/node_modules/tar/README.md index fc55bc36fee39..262dd063eb590 100644 --- a/node_modules/tar/README.md +++ b/node_modules/tar/README.md @@ -230,6 +230,9 @@ The following options are supported: Note that this prevents using other mtime-based features like `tar.update` or the `keepNewer` option with the resulting tar archive. [Alias: `m`, `no-mtime`] +- `mtime` Set to a `Date` object to force a specific `mtime` for + everything added to the archive. Overridden by `noMtime`. + The following options are mostly internal, but can be modified in some advanced use cases, such as re-using caches between runs. diff --git a/node_modules/tar/lib/header.js b/node_modules/tar/lib/header.js index cad4aec255148..d29c3b9906ff2 100644 --- a/node_modules/tar/lib/header.js +++ b/node_modules/tar/lib/header.js @@ -9,10 +9,11 @@ const types = require('./types.js') const pathModule = require('path').posix const large = require('./large-numbers.js') +const SLURP = Symbol('slurp') const TYPE = Symbol('type') class Header { - constructor (data, off) { + constructor (data, off, ex, gex) { this.cksumValid = false this.needPax = false this.nullBlock = false @@ -35,12 +36,12 @@ class Header { this.ctime = null if (Buffer.isBuffer(data)) - this.decode(data, off || 0) + this.decode(data, off || 0, ex, gex) else if (data) this.set(data) } - decode (buf, off) { + decode (buf, off, ex, gex) { if (!off) off = 0 @@ -55,6 +56,11 @@ class Header { this.mtime = decDate(buf, off + 136, 12) this.cksum = decNumber(buf, off + 148, 12) + // if we have extended or global extended headers, apply them now + // See https://github.com/npm/node-tar/pull/187 + this[SLURP](ex) + this[SLURP](gex, true) + // old tar versions marked dirs as a file with a trailing / this[TYPE] = decString(buf, off + 156, 1) if (this[TYPE] === '') @@ -101,6 +107,16 @@ class Header { this.nullBlock = true } + [SLURP] (ex, global) { + for (let k in ex) { + // we slurp in everything except for the path attribute in + // a global extended header, because that's weird. + if (ex[k] !== null && ex[k] !== undefined && + !(global && k === 'path')) + this[k] = ex[k] + } + } + encode (buf, off) { if (!buf) { buf = this.block = Buffer.alloc(512) diff --git a/node_modules/tar/lib/parse.js b/node_modules/tar/lib/parse.js index 2a73b2bb726f8..df84079fd370a 100644 --- a/node_modules/tar/lib/parse.js +++ b/node_modules/tar/lib/parse.js @@ -101,7 +101,7 @@ module.exports = warner(class Parser extends EE { } [CONSUMEHEADER] (chunk, position) { - const header = new Header(chunk, position) + const header = new Header(chunk, position, this[EX], this[GEX]) if (header.nullBlock) this[EMIT]('nullBlock') diff --git a/node_modules/tar/lib/unpack.js b/node_modules/tar/lib/unpack.js index 5b79cda09afce..dcbdd19e1c860 100644 --- a/node_modules/tar/lib/unpack.js +++ b/node_modules/tar/lib/unpack.js @@ -331,8 +331,10 @@ class Unpack extends Parser { }) const tx = this.transform ? this.transform(entry) || entry : entry - if (tx !== entry) + if (tx !== entry) { + tx.on('error', er => this[ONERROR](er, entry)) entry.pipe(tx) + } tx.pipe(stream) } @@ -512,8 +514,10 @@ class UnpackSync extends Unpack { return oner(er) } const tx = this.transform ? this.transform(entry) || entry : entry - if (tx !== entry) + if (tx !== entry) { + tx.on('error', er => this[ONERROR](er, entry)) entry.pipe(tx) + } tx.on('data', chunk => { try { diff --git a/node_modules/tar/package.json b/node_modules/tar/package.json index a4b9e0053f78d..5cfb10128ed3e 100644 --- a/node_modules/tar/package.json +++ b/node_modules/tar/package.json @@ -1,29 +1,29 @@ { - "_from": "tar@4.4.4", - "_id": "tar@4.4.4", + "_from": "tar@4.4.6", + "_id": "tar@4.4.6", "_inBundle": false, - "_integrity": "sha512-mq9ixIYfNF9SK0IS/h2HKMu8Q2iaCuhDDsZhdEag/FHv8fOaYld4vN7ouMgcSSt5WKZzPs8atclTcJm36OTh4w==", + "_integrity": "sha512-tMkTnh9EdzxyfW+6GK6fCahagXsnYk6kE6S9Gr9pjVdys769+laCTbodXDhPAjzVtEBazRgP0gYqOjnk9dQzLg==", "_location": "/tar", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "tar@4.4.4", + "raw": "tar@4.4.6", "name": "tar", "escapedName": "tar", - "rawSpec": "4.4.4", + "rawSpec": "4.4.6", "saveSpec": null, - "fetchSpec": "4.4.4" + "fetchSpec": "4.4.6" }, "_requiredBy": [ "#USER", "/", "/pacote" ], - "_resolved": "https://registry.npmjs.org/tar/-/tar-4.4.4.tgz", - "_shasum": "ec8409fae9f665a4355cc3b4087d0820232bb8cd", - "_spec": "tar@4.4.4", - "_where": "/Users/rebecca/code/npm", + "_resolved": "https://registry.npmjs.org/tar/-/tar-4.4.6.tgz", + "_shasum": "63110f09c00b4e60ac8bcfe1bf3c8660235fbc9b", + "_spec": "tar@4.4.6", + "_where": "/Users/zkat/Documents/code/work/npm", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -76,5 +76,5 @@ "preversion": "npm test", "test": "tap test/*.js --100 -J --coverage-report=text -c" }, - "version": "4.4.4" + "version": "4.4.6" } diff --git a/package-lock.json b/package-lock.json index 0a29984f33e1d..46b6ad68eea1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7430,9 +7430,9 @@ } }, "tar": { - "version": "4.4.4", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.4.tgz", - "integrity": "sha512-mq9ixIYfNF9SK0IS/h2HKMu8Q2iaCuhDDsZhdEag/FHv8fOaYld4vN7ouMgcSSt5WKZzPs8atclTcJm36OTh4w==", + "version": "4.4.6", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.6.tgz", + "integrity": "sha512-tMkTnh9EdzxyfW+6GK6fCahagXsnYk6kE6S9Gr9pjVdys769+laCTbodXDhPAjzVtEBazRgP0gYqOjnk9dQzLg==", "requires": { "chownr": "^1.0.1", "fs-minipass": "^1.2.5", diff --git a/package.json b/package.json index 213ad8001eb5d..50b62de6df8ca 100644 --- a/package.json +++ b/package.json @@ -127,7 +127,7 @@ "sorted-union-stream": "~2.1.3", "ssri": "^6.0.0", "stringify-package": "^1.0.0", - "tar": "^4.4.4", + "tar": "^4.4.6", "text-table": "~0.2.0", "tiny-relative-date": "^1.3.0", "uid-number": "0.0.6",