tar 5.0.5 → 5.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/strip-absolute-path.js +14 -0
- package/lib/unpack.js +5 -5
- package/lib/write-entry.js +13 -10
- package/package.json +4 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// unix absolute paths are also absolute on win32, so we use this for both
|
|
2
|
+
const { isAbsolute, parse } = require('path').win32
|
|
3
|
+
|
|
4
|
+
// returns [root, stripped]
|
|
5
|
+
module.exports = path => {
|
|
6
|
+
let r = ''
|
|
7
|
+
while (isAbsolute(path)) {
|
|
8
|
+
// windows will think that //x/y/z has a "root" of //x/y/
|
|
9
|
+
const root = path.charAt(0) === '/' ? '/' : parse(path).root
|
|
10
|
+
path = path.substr(root.length)
|
|
11
|
+
r += root
|
|
12
|
+
}
|
|
13
|
+
return [r, path]
|
|
14
|
+
}
|
package/lib/unpack.js
CHANGED
|
@@ -16,6 +16,7 @@ const mkdir = require('./mkdir.js')
|
|
|
16
16
|
const mkdirSync = mkdir.sync
|
|
17
17
|
const wc = require('./winchars.js')
|
|
18
18
|
const pathReservations = require('./path-reservations.js')
|
|
19
|
+
const stripAbsolutePath = require('./strip-absolute-path.js')
|
|
19
20
|
|
|
20
21
|
const ONENTRY = Symbol('onEntry')
|
|
21
22
|
const CHECKFS = Symbol('checkFs')
|
|
@@ -223,11 +224,10 @@ class Unpack extends Parser {
|
|
|
223
224
|
|
|
224
225
|
// absolutes on posix are also absolutes on win32
|
|
225
226
|
// so we only need to test this one to get both
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
entry.path =
|
|
229
|
-
|
|
230
|
-
this.warn('TAR_ENTRY_INFO', `stripping ${r} from absolute path`, {
|
|
227
|
+
const [root, stripped] = stripAbsolutePath(p)
|
|
228
|
+
if (root) {
|
|
229
|
+
entry.path = stripped
|
|
230
|
+
this.warn('TAR_ENTRY_INFO', `stripping ${root} from absolute path`, {
|
|
231
231
|
entry,
|
|
232
232
|
path: p,
|
|
233
233
|
})
|
package/lib/write-entry.js
CHANGED
|
@@ -25,6 +25,7 @@ const CLOSE = Symbol('close')
|
|
|
25
25
|
const MODE = Symbol('mode')
|
|
26
26
|
const warner = require('./warn-mixin.js')
|
|
27
27
|
const winchars = require('./winchars.js')
|
|
28
|
+
const stripAbsolutePath = require('./strip-absolute-path.js')
|
|
28
29
|
|
|
29
30
|
const modeFix = require('./mode-fix.js')
|
|
30
31
|
|
|
@@ -54,12 +55,12 @@ const WriteEntry = warner(class WriteEntry extends MiniPass {
|
|
|
54
55
|
this.on('warn', opt.onwarn)
|
|
55
56
|
|
|
56
57
|
let pathWarn = false
|
|
57
|
-
if (!this.preservePaths
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
if (!this.preservePaths) {
|
|
59
|
+
const [root, stripped] = stripAbsolutePath(this.path)
|
|
60
|
+
if (root) {
|
|
61
|
+
this.path = stripped
|
|
62
|
+
pathWarn = root
|
|
63
|
+
}
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
this.win32 = !!opt.win32 || process.platform === 'win32'
|
|
@@ -353,10 +354,12 @@ const WriteEntryTar = warner(class WriteEntryTar extends MiniPass {
|
|
|
353
354
|
this.on('warn', opt.onwarn)
|
|
354
355
|
|
|
355
356
|
let pathWarn = false
|
|
356
|
-
if (
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
357
|
+
if (!this.preservePaths) {
|
|
358
|
+
const [root, stripped] = stripAbsolutePath(this.path)
|
|
359
|
+
if (root) {
|
|
360
|
+
this.path = stripped
|
|
361
|
+
pathWarn = root
|
|
362
|
+
}
|
|
360
363
|
}
|
|
361
364
|
|
|
362
365
|
this.remain = readEntry.size
|
package/package.json
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
|
3
3
|
"name": "tar",
|
|
4
4
|
"description": "tar for node",
|
|
5
|
-
"version": "5.0.
|
|
5
|
+
"version": "5.0.6",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"tag": "v5-legacy"
|
|
8
|
+
},
|
|
6
9
|
"repository": {
|
|
7
10
|
"type": "git",
|
|
8
11
|
"url": "https://github.com/npm/node-tar.git"
|