diff options
author | Gar <gar+gh@danger.computer> | 2021-07-26 18:59:04 +0300 |
---|---|---|
committer | Gar <gar+gh@danger.computer> | 2021-07-26 18:59:04 +0300 |
commit | f5aab1f8878b4e9a6f4d47dddc449e18a190e201 (patch) | |
tree | e4d70fb8d11f9a7ff0fd594c0fdf9b81dbcde271 /node_modules | |
parent | ced85087ac5fce5984ae28af910357a9a94434d7 (diff) |
tar@6.1.1
Diffstat (limited to 'node_modules')
-rw-r--r-- | node_modules/tar/lib/strip-absolute-path.js | 14 | ||||
-rw-r--r-- | node_modules/tar/lib/unpack.js | 10 | ||||
-rw-r--r-- | node_modules/tar/lib/write-entry.js | 23 | ||||
-rw-r--r-- | node_modules/tar/package.json | 4 |
4 files changed, 34 insertions, 17 deletions
diff --git a/node_modules/tar/lib/strip-absolute-path.js b/node_modules/tar/lib/strip-absolute-path.js new file mode 100644 index 000000000..49161ddc3 --- /dev/null +++ b/node_modules/tar/lib/strip-absolute-path.js @@ -0,0 +1,14 @@ +// unix absolute paths are also absolute on win32, so we use this for both +const { isAbsolute, parse } = require('path').win32 + +// returns [root, stripped] +module.exports = path => { + let r = '' + while (isAbsolute(path)) { + // windows will think that //x/y/z has a "root" of //x/y/ + const root = path.charAt(0) === '/' ? '/' : parse(path).root + path = path.substr(root.length) + r += root + } + return [r, path] +} diff --git a/node_modules/tar/lib/unpack.js b/node_modules/tar/lib/unpack.js index 7d4b79d9e..216fa71bd 100644 --- a/node_modules/tar/lib/unpack.js +++ b/node_modules/tar/lib/unpack.js @@ -14,6 +14,7 @@ const path = require('path') const mkdir = require('./mkdir.js') const wc = require('./winchars.js') const pathReservations = require('./path-reservations.js') +const stripAbsolutePath = require('./strip-absolute-path.js') const ONENTRY = Symbol('onEntry') const CHECKFS = Symbol('checkFs') @@ -224,11 +225,10 @@ class Unpack extends Parser { // absolutes on posix are also absolutes on win32 // so we only need to test this one to get both - if (path.win32.isAbsolute(p)) { - const parsed = path.win32.parse(p) - entry.path = p.substr(parsed.root.length) - const r = parsed.root - this.warn('TAR_ENTRY_INFO', `stripping ${r} from absolute path`, { + const [root, stripped] = stripAbsolutePath(p) + if (root) { + entry.path = stripped + this.warn('TAR_ENTRY_INFO', `stripping ${root} from absolute path`, { entry, path: p, }) diff --git a/node_modules/tar/lib/write-entry.js b/node_modules/tar/lib/write-entry.js index 1d0b746cd..0301759ad 100644 --- a/node_modules/tar/lib/write-entry.js +++ b/node_modules/tar/lib/write-entry.js @@ -23,6 +23,7 @@ const CLOSE = Symbol('close') const MODE = Symbol('mode') const warner = require('./warn-mixin.js') const winchars = require('./winchars.js') +const stripAbsolutePath = require('./strip-absolute-path.js') const modeFix = require('./mode-fix.js') @@ -52,12 +53,12 @@ const WriteEntry = warner(class WriteEntry extends MiniPass { this.on('warn', opt.onwarn) let pathWarn = false - if (!this.preservePaths && path.win32.isAbsolute(p)) { - // absolutes on posix are also absolutes on win32 - // so we only need to test this one to get both - const parsed = path.win32.parse(p) - this.path = p.substr(parsed.root.length) - pathWarn = parsed.root + if (!this.preservePaths) { + const [root, stripped] = stripAbsolutePath(this.path) + if (root) { + this.path = stripped + pathWarn = root + } } this.win32 = !!opt.win32 || process.platform === 'win32' @@ -351,10 +352,12 @@ const WriteEntryTar = warner(class WriteEntryTar extends MiniPass { this.on('warn', opt.onwarn) let pathWarn = false - if (path.isAbsolute(this.path) && !this.preservePaths) { - const parsed = path.parse(this.path) - pathWarn = parsed.root - this.path = this.path.substr(parsed.root.length) + if (!this.preservePaths) { + const [root, stripped] = stripAbsolutePath(this.path) + if (root) { + this.path = stripped + pathWarn = root + } } this.remain = readEntry.size diff --git a/node_modules/tar/package.json b/node_modules/tar/package.json index 9b8b96ec6..c497349c9 100644 --- a/node_modules/tar/package.json +++ b/node_modules/tar/package.json @@ -2,7 +2,7 @@ "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)", "name": "tar", "description": "tar for node", - "version": "6.1.0", + "version": "6.1.1", "repository": { "type": "git", "url": "https://github.com/npm/node-tar.git" @@ -38,7 +38,7 @@ "events-to-array": "^1.1.2", "mutate-fs": "^2.1.1", "rimraf": "^2.7.1", - "tap": "^14.9.2", + "tap": "^15.0.9", "tar-fs": "^1.16.3", "tar-stream": "^1.6.2" }, |