Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
fix(deps): update tar-fs with the special characters patch (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcibique authored and zkat committed Jun 10, 2017
1 parent c45a699 commit ed43aa3
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 9 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"safe-buffer": "^5.1.0",
"semver": "^5.3.0",
"ssri": "^4.1.5",
"tar-fs": "^1.15.1",
"tar-fs": "^1.15.3",
"tar-stream": "^1.5.4",
"unique-filename": "^1.1.0",
"which": "^1.2.12"
Expand Down
40 changes: 40 additions & 0 deletions test/extract-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const BB = require('bluebird')
const fs = BB.promisifyAll(require('fs'))
const mockTar = require('./util/mock-tarball')
const npmlog = require('npmlog')
const path = require('path')
const pipe = BB.promisify(require('mississippi').pipe)
const test = require('tap').test

Expand Down Expand Up @@ -241,3 +242,42 @@ test('accepts dmode/fmode/umask opts', {
)
})
})

test('extracts filenames with special characters', {
skip: process.platform !== 'win32'
}, t => {
const tarStream = fs.createReadStream('../../fixtures/special-characters.tgz');
const workingDir = './special-characters/'
return pipe(tarStream, extractStream(workingDir))
.then(() => {
const fileNamesUnderTest = [
'filename:with:colons',
'filename<with<less<than<signs',
'filename>with>more>than>signs',
'filename|with|pipes',
'filename?with?question?marks'
].map(fileName => {
return {
rawFileName: fileName,
expectedFileName: fileName.replace(/[:?<>|]/g, '_'),
expectedContent: fileName
}
})

return BB.all(fileNamesUnderTest.map(fileNameUnderTest => {
return fs.readFileAsync(path.join(workingDir, fileNameUnderTest.expectedFileName), 'utf8')
.then(data => {
t.equal(data.trim(), fileNameUnderTest.expectedContent, 'Filename "' + fileNameUnderTest.rawFileName + '" was sanitized and content left intact')
})
.catch(err => {
return BB.reject(new Error('Filename "' + fileNameUnderTest.rawFileName + '" was not extracted: ' + err))
})
}))
})
.catch(err => {
if (err.code === 'ENOENT') {
return BB.reject(new Error('Unable to extract the tarball with special characters in filenames.'))
}
return BB.reject(err)
})
});
9 changes: 5 additions & 4 deletions test/fixtures/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
This directory contains a number of pre-generated files and directories used
by various tests. This file documents which tests use each file, and what for.

| File | User(s) | Note |
|----------------------|------------------------------|-----------------------------------------------|
| `has-shrinkwrap.tgz` | `util.extract-shrinkwrap.js` | used to test streaming shrinkwrap extraction. |
| `no-shrinkwrap.tgz` | `util.extract-shrinkwrap.js` | used to test streaming shrinkwrap extraction. |
| File | User(s) | Note |
|---------------------------|------------------------------|-----------------------------------------------------------|
| `has-shrinkwrap.tgz` | `util.extract-shrinkwrap.js` | used to test streaming shrinkwrap extraction. |
| `no-shrinkwrap.tgz` | `util.extract-shrinkwrap.js` | used to test streaming shrinkwrap extraction. |
| `special-characters.tgz` | `util.extract-shrinkwrap.js` | used to test sanitization of special characters on win32. |
Binary file added test/fixtures/special-characters.tgz
Binary file not shown.

0 comments on commit ed43aa3

Please sign in to comment.