tar 4.4.13 → 4.4.14

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.
@@ -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
@@ -9,6 +9,7 @@ const path = require('path')
9
9
  const mkdir = require('./mkdir.js')
10
10
  const mkdirSync = mkdir.sync
11
11
  const wc = require('./winchars.js')
12
+ const stripAbsolutePath = require('./strip-absolute-path.js')
12
13
 
13
14
  const ONENTRY = Symbol('onEntry')
14
15
  const CHECKFS = Symbol('checkFs')
@@ -195,10 +196,10 @@ class Unpack extends Parser {
195
196
 
196
197
  // absolutes on posix are also absolutes on win32
197
198
  // so we only need to test this one to get both
198
- if (path.win32.isAbsolute(p)) {
199
- const parsed = path.win32.parse(p)
200
- this.warn('stripping ' + parsed.root + ' from absolute path', p)
201
- entry.path = p.substr(parsed.root.length)
199
+ const s = stripAbsolutePath(p)
200
+ if (s[0]) {
201
+ entry.path = s[1]
202
+ this.warn(`stripping ${s[0]} from absolute path`, p)
202
203
  }
203
204
  }
204
205
 
@@ -26,6 +26,7 @@ const CLOSE = Symbol('close')
26
26
  const MODE = Symbol('mode')
27
27
  const warner = require('./warn-mixin.js')
28
28
  const winchars = require('./winchars.js')
29
+ const stripAbsolutePath = require('./strip-absolute-path.js')
29
30
 
30
31
  const modeFix = require('./mode-fix.js')
31
32
 
@@ -54,12 +55,12 @@ const WriteEntry = warner(class WriteEntry extends MiniPass {
54
55
  if (typeof opt.onwarn === 'function')
55
56
  this.on('warn', opt.onwarn)
56
57
 
57
- if (!this.preservePaths && path.win32.isAbsolute(p)) {
58
- // absolutes on posix are also absolutes on win32
59
- // so we only need to test this one to get both
60
- const parsed = path.win32.parse(p)
61
- this.warn('stripping ' + parsed.root + ' from absolute path', p)
62
- this.path = p.substr(parsed.root.length)
58
+ if (!this.preservePaths) {
59
+ const s = stripAbsolutePath(this.path)
60
+ if (s[0]) {
61
+ this.path = s[1]
62
+ this.warn('stripping ' + s[0] + ' from absolute path', p)
63
+ }
63
64
  }
64
65
 
65
66
  this.win32 = !!opt.win32 || process.platform === 'win32'
@@ -343,13 +344,15 @@ const WriteEntryTar = warner(class WriteEntryTar extends MiniPass {
343
344
  if (typeof opt.onwarn === 'function')
344
345
  this.on('warn', opt.onwarn)
345
346
 
346
- if (path.isAbsolute(this.path) && !this.preservePaths) {
347
- const parsed = path.parse(this.path)
348
- this.warn(
349
- 'stripping ' + parsed.root + ' from absolute path',
350
- this.path
351
- )
352
- this.path = this.path.substr(parsed.root.length)
347
+ if (!this.preservePaths) {
348
+ const s = stripAbsolutePath(this.path)
349
+ if (s[0]) {
350
+ this.warn(
351
+ 'stripping ' + s[0] + ' from absolute path',
352
+ this.path
353
+ )
354
+ this.path = s[1]
355
+ }
353
356
  }
354
357
 
355
358
  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": "4.4.13",
5
+ "version": "4.4.14",
6
+ "publishConfig": {
7
+ "tag": "v4-legacy"
8
+ },
6
9
  "repository": {
7
10
  "type": "git",
8
11
  "url": "https://github.com/npm/node-tar.git"