Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarcy Clarke <darcy@darcyclarke.me>2021-07-27 23:52:57 +0300
committerRichard Lau <rlau@redhat.com>2021-07-28 21:39:03 +0300
commitacf5279c3934b55480567b2c30ac63ad7256822a (patch)
treedb5601c5931f41614133f5d31499ad1ef26f1d94 /deps/npm/node_modules/tar/lib
parentd48b91ea2b27828ceea10dab1effa42bc542be03 (diff)
deps: upgrade npm to 6.14.14
PR-URL: https://github.com/nodejs/node/pull/39553 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Diffstat (limited to 'deps/npm/node_modules/tar/lib')
-rw-r--r--deps/npm/node_modules/tar/lib/strip-absolute-path.js14
-rw-r--r--deps/npm/node_modules/tar/lib/unpack.js32
-rw-r--r--deps/npm/node_modules/tar/lib/write-entry.js29
3 files changed, 58 insertions, 17 deletions
diff --git a/deps/npm/node_modules/tar/lib/strip-absolute-path.js b/deps/npm/node_modules/tar/lib/strip-absolute-path.js
new file mode 100644
index 00000000000..49161ddc304
--- /dev/null
+++ b/deps/npm/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/deps/npm/node_modules/tar/lib/unpack.js b/deps/npm/node_modules/tar/lib/unpack.js
index fc765096efd..3a29a65142e 100644
--- a/deps/npm/node_modules/tar/lib/unpack.js
+++ b/deps/npm/node_modules/tar/lib/unpack.js
@@ -9,6 +9,7 @@ const path = require('path')
const mkdir = require('./mkdir.js')
const mkdirSync = mkdir.sync
const wc = require('./winchars.js')
+const stripAbsolutePath = require('./strip-absolute-path.js')
const ONENTRY = Symbol('onEntry')
const CHECKFS = Symbol('checkFs')
@@ -195,10 +196,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)
- this.warn('stripping ' + parsed.root + ' from absolute path', p)
- entry.path = p.substr(parsed.root.length)
+ const s = stripAbsolutePath(p)
+ if (s[0]) {
+ entry.path = s[1]
+ this.warn(`stripping ${s[0]} from absolute path`, p)
}
}
@@ -413,6 +414,20 @@ class Unpack extends Parser {
// check if a thing is there, and if so, try to clobber it
[CHECKFS] (entry) {
this[PEND]()
+
+ // if we are not creating a directory, and the path is in the dirCache,
+ // then that means we are about to delete the directory we created
+ // previously, and it is no longer going to be a directory, and neither
+ // is any of its children.
+ if (entry.type !== 'Directory') {
+ for (const path of this.dirCache.keys()) {
+ if (path === entry.absolute ||
+ path.indexOf(entry.absolute + '/') === 0 ||
+ path.indexOf(entry.absolute + '\\') === 0)
+ this.dirCache.delete(path)
+ }
+ }
+
this[MKDIR](path.dirname(entry.absolute), this.dmode, er => {
if (er)
return this[ONERROR](er, entry)
@@ -474,6 +489,15 @@ class UnpackSync extends Unpack {
}
[CHECKFS] (entry) {
+ if (entry.type !== 'Directory') {
+ for (const path of this.dirCache.keys()) {
+ if (path === entry.absolute ||
+ path.indexOf(entry.absolute + '/') === 0 ||
+ path.indexOf(entry.absolute + '\\') === 0)
+ this.dirCache.delete(path)
+ }
+ }
+
const er = this[MKDIR](path.dirname(entry.absolute), this.dmode)
if (er)
return this[ONERROR](er, entry)
diff --git a/deps/npm/node_modules/tar/lib/write-entry.js b/deps/npm/node_modules/tar/lib/write-entry.js
index 0c019006f3b..d7c347f8f62 100644
--- a/deps/npm/node_modules/tar/lib/write-entry.js
+++ b/deps/npm/node_modules/tar/lib/write-entry.js
@@ -26,6 +26,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')
@@ -54,12 +55,12 @@ const WriteEntry = warner(class WriteEntry extends MiniPass {
if (typeof opt.onwarn === 'function')
this.on('warn', opt.onwarn)
- 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.warn('stripping ' + parsed.root + ' from absolute path', p)
- this.path = p.substr(parsed.root.length)
+ if (!this.preservePaths) {
+ const s = stripAbsolutePath(this.path)
+ if (s[0]) {
+ this.path = s[1]
+ this.warn('stripping ' + s[0] + ' from absolute path', p)
+ }
}
this.win32 = !!opt.win32 || process.platform === 'win32'
@@ -343,13 +344,15 @@ const WriteEntryTar = warner(class WriteEntryTar extends MiniPass {
if (typeof opt.onwarn === 'function')
this.on('warn', opt.onwarn)
- if (path.isAbsolute(this.path) && !this.preservePaths) {
- const parsed = path.parse(this.path)
- this.warn(
- 'stripping ' + parsed.root + ' from absolute path',
- this.path
- )
- this.path = this.path.substr(parsed.root.length)
+ if (!this.preservePaths) {
+ const s = stripAbsolutePath(this.path)
+ if (s[0]) {
+ this.warn(
+ 'stripping ' + s[0] + ' from absolute path',
+ this.path
+ )
+ this.path = s[1]
+ }
}
this.remain = readEntry.size