diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/tar-stream | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/tar-stream')
-rw-r--r-- | node_modules/tar-stream/extract.js | 18 | ||||
-rw-r--r-- | node_modules/tar-stream/headers.js | 31 | ||||
-rw-r--r-- | node_modules/tar-stream/pack.js | 9 | ||||
-rw-r--r-- | node_modules/tar-stream/package.json | 16 |
4 files changed, 44 insertions, 30 deletions
diff --git a/node_modules/tar-stream/extract.js b/node_modules/tar-stream/extract.js index 8be2a472c..19a4255a3 100644 --- a/node_modules/tar-stream/extract.js +++ b/node_modules/tar-stream/extract.js @@ -22,6 +22,7 @@ var emptyStream = function (self, offset) { var mixinPax = function (header, pax) { if (pax.path) header.name = pax.path if (pax.linkpath) header.linkname = pax.linkpath + if (pax.size) header.size = parseInt(pax.size, 10) header.pax = pax return header } @@ -42,9 +43,12 @@ var Extract = function (opts) { if (!(this instanceof Extract)) return new Extract(opts) Writable.call(this, opts) + opts = opts || {} + this._offset = 0 this._buffer = bl() this._missing = 0 + this._partial = false this._onparse = noop this._header = null this._stream = null @@ -101,14 +105,14 @@ var Extract = function (opts) { var ongnulongpath = function () { var size = self._header.size - this._gnuLongPath = headers.decodeLongPath(b.slice(0, size)) + this._gnuLongPath = headers.decodeLongPath(b.slice(0, size), opts.filenameEncoding) b.consume(size) onstreamend() } var ongnulonglinkpath = function () { var size = self._header.size - this._gnuLongLinkPath = headers.decodeLongPath(b.slice(0, size)) + this._gnuLongLinkPath = headers.decodeLongPath(b.slice(0, size), opts.filenameEncoding) b.consume(size) onstreamend() } @@ -117,7 +121,7 @@ var Extract = function (opts) { var offset = self._offset var header try { - header = self._header = headers.decode(b.slice(0, 512)) + header = self._header = headers.decode(b.slice(0, 512), opts.filenameEncoding) } catch (err) { self.emit('error', err) } @@ -179,6 +183,7 @@ var Extract = function (opts) { oncontinue() } + this._onheader = onheader this._parse(512, onheader) } @@ -197,6 +202,7 @@ Extract.prototype._parse = function (size, onparse) { if (this._destroyed) return this._offset += size this._missing = size + if (onparse === this._onheader) this._partial = false this._onparse = onparse } @@ -214,6 +220,7 @@ Extract.prototype._write = function (data, enc, cb) { var s = this._stream var b = this._buffer var missing = this._missing + if (data.length) this._partial = true // we do not reach end-of-chunk now. just forward it @@ -243,4 +250,9 @@ Extract.prototype._write = function (data, enc, cb) { this._onparse() } +Extract.prototype._final = function (cb) { + if (this._partial) return this.destroy(new Error('Unexpected end of data')) + cb() +} + module.exports = Extract diff --git a/node_modules/tar-stream/headers.js b/node_modules/tar-stream/headers.js index 8aab8b561..6efbc4a3a 100644 --- a/node_modules/tar-stream/headers.js +++ b/node_modules/tar-stream/headers.js @@ -1,3 +1,6 @@ +var toBuffer = require('to-buffer') +var alloc = require('buffer-alloc') + var ZEROS = '0000000000000000000' var SEVENS = '7777777777777777777' var ZERO_OFFSET = '0'.charCodeAt(0) @@ -6,7 +9,7 @@ var MASK = parseInt('7777', 8) var clamp = function (index, len, defaultValue) { if (typeof index !== 'number') return defaultValue - index = ~~index // Coerce to integer. + index = ~~index // Coerce to integer. if (index >= len) return len if (index >= 0) return index index += len @@ -71,12 +74,6 @@ var toTypeflag = function (flag) { return 0 } -var alloc = function (size) { - var buf = new Buffer(size) - buf.fill(0) - return buf -} - var indexOf = function (block, num, offset, end) { for (; offset < end; offset++) { if (block[offset] === num) return offset @@ -149,20 +146,20 @@ var decodeOct = function (val, offset, length) { } } -var decodeStr = function (val, offset, length) { - return val.slice(offset, indexOf(val, 0, offset, offset + length)).toString() +var decodeStr = function (val, offset, length, encoding) { + return val.slice(offset, indexOf(val, 0, offset, offset + length)).toString(encoding) } var addLength = function (str) { var len = Buffer.byteLength(str) var digits = Math.floor(Math.log(len) / Math.log(10)) + 1 - if (len + digits > Math.pow(10, digits)) digits++ + if (len + digits >= Math.pow(10, digits)) digits++ return (len + digits) + str } -exports.decodeLongPath = function (buf) { - return decodeStr(buf, 0, buf.length) +exports.decodeLongPath = function (buf, encoding) { + return decodeStr(buf, 0, buf.length, encoding) } exports.encodePax = function (opts) { // TODO: encode more stuff in pax @@ -175,7 +172,7 @@ exports.encodePax = function (opts) { // TODO: encode more stuff in pax result += addLength(' ' + key + '=' + pax[key] + '\n') } } - return new Buffer(result) + return toBuffer(result) } exports.decodePax = function (buf) { @@ -240,23 +237,23 @@ exports.encode = function (opts) { return buf } -exports.decode = function (buf) { +exports.decode = function (buf, filenameEncoding) { var typeflag = buf[156] === 0 ? 0 : buf[156] - ZERO_OFFSET - var name = decodeStr(buf, 0, 100) + var name = decodeStr(buf, 0, 100, filenameEncoding) var mode = decodeOct(buf, 100, 8) var uid = decodeOct(buf, 108, 8) var gid = decodeOct(buf, 116, 8) var size = decodeOct(buf, 124, 12) var mtime = decodeOct(buf, 136, 12) var type = toType(typeflag) - var linkname = buf[157] === 0 ? null : decodeStr(buf, 157, 100) + var linkname = buf[157] === 0 ? null : decodeStr(buf, 157, 100, filenameEncoding) var uname = decodeStr(buf, 265, 32) var gname = decodeStr(buf, 297, 32) var devmajor = decodeOct(buf, 329, 8) var devminor = decodeOct(buf, 337, 8) - if (buf[345]) name = decodeStr(buf, 345, 155) + '/' + name + if (buf[345]) name = decodeStr(buf, 345, 155, filenameEncoding) + '/' + name // to support old tar versions that use trailing / to indicate dirs if (typeflag === 0 && name && name[name.length - 1] === '/') typeflag = 5 diff --git a/node_modules/tar-stream/pack.js b/node_modules/tar-stream/pack.js index 025f00713..72d96a0c7 100644 --- a/node_modules/tar-stream/pack.js +++ b/node_modules/tar-stream/pack.js @@ -1,6 +1,8 @@ -var constants = require('constants') +var constants = require('fs-constants') var eos = require('end-of-stream') var util = require('util') +var alloc = require('buffer-alloc') +var toBuffer = require('to-buffer') var Readable = require('readable-stream').Readable var Writable = require('readable-stream').Writable @@ -11,8 +13,7 @@ var headers = require('./headers') var DMODE = parseInt('755', 8) var FMODE = parseInt('644', 8) -var END_OF_TAR = new Buffer(1024) -END_OF_TAR.fill(0) +var END_OF_TAR = alloc(1024) var noop = function () {} @@ -124,7 +125,7 @@ Pack.prototype.entry = function (header, buffer, callback) { if (!header.gid) header.gid = 0 if (!header.mtime) header.mtime = new Date() - if (typeof buffer === 'string') buffer = new Buffer(buffer) + if (typeof buffer === 'string') buffer = toBuffer(buffer) if (Buffer.isBuffer(buffer)) { header.size = buffer.length this._encode(header) diff --git a/node_modules/tar-stream/package.json b/node_modules/tar-stream/package.json index 5e2bd7b64..aad41c913 100644 --- a/node_modules/tar-stream/package.json +++ b/node_modules/tar-stream/package.json @@ -1,6 +1,6 @@ { "name": "tar-stream", - "version": "1.5.4", + "version": "1.6.1", "description": "tar-stream is a streaming tar parser and generator and nothing else. It is streams2 and operates purely using streams which means you can easily extract/parse tarballs without ever hitting the file system.", "author": "Mathias Buus <mathiasbuus@gmail.com>", "engines": { @@ -8,17 +8,21 @@ }, "dependencies": { "bl": "^1.0.0", + "buffer-alloc": "^1.1.0", "end-of-stream": "^1.0.0", - "readable-stream": "^2.0.0", + "fs-constants": "^1.0.0", + "readable-stream": "^2.3.0", + "to-buffer": "^1.1.0", "xtend": "^4.0.0" }, "devDependencies": { - "concat-stream": "^1.4.6", - "standard": "^5.3.1", - "tape": "^3.0.3" + "concat-stream": "^1.6.2", + "standard": "^11.0.1", + "tape": "^4.9.0" }, "scripts": { - "test": "standard && tape test/*.js" + "test": "standard && tape test/extract.js test/pack.js", + "test-all": "standard && tape test/*.js" }, "keywords": [ "tar", |