Skip to content

Commit

Permalink
Handle dots within filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
trptcolin committed Feb 27, 2020
1 parent 3788e03 commit e6eeb3d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Binary file added fixtures/edge_case_dots.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const extractFile = (input, output, opts) => runPlugins(input, opts).then(files

return Promise.all(files.map(x => {
const dest = path.join(output, x.path);
if (dest.match(/\.\./)) {
if (dest.match(/\.\.\//)) {
throw (new Error('File path contains "..":', dest));
}

Expand Down
6 changes: 6 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,9 @@ test('throw when a location outside the root is given', async t => {
await m(path.join(__dirname, 'fixtures', 'slipping.tar.gz'), 'dist');
}, {message: /File path contains "\.\."/});
});

test('allows filenames to be written with dots in them', async t => {
const files = await m(path.join(__dirname, 'fixtures', 'edge_case_dots.tar.gz'), __dirname);
t.is(files.length, 3);
await fsP.rmdir(path.join(__dirname, 'edge_case_dots'), {recursive: true});
});

0 comments on commit e6eeb3d

Please sign in to comment.