diff --git a/fixtures/edge_case_dots.tar.gz b/fixtures/edge_case_dots.tar.gz new file mode 100644 index 0000000..c514580 Binary files /dev/null and b/fixtures/edge_case_dots.tar.gz differ diff --git a/index.js b/index.js index ba3ec6a..19bc34f 100644 --- a/index.js +++ b/index.js @@ -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)); } diff --git a/test.js b/test.js index 04bcc28..19f5665 100644 --- a/test.js +++ b/test.js @@ -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}); +});