Strip spaces from octal fields for old tars
This commit is contained in:
parent
4cfa377cba
commit
a6f9c6f8a9
4 changed files with 23 additions and 2 deletions
|
@ -90,6 +90,9 @@ var encodeOct = function(val, n) {
|
|||
};
|
||||
|
||||
var decodeOct = function(val, offset) {
|
||||
// Older versions of tar can prefix with spaces
|
||||
while (val[offset] === 32) offset += 1;
|
||||
|
||||
return parseInt(val.slice(offset, clamp(indexOf(val, 32, offset, val.length), val.length, val.length)).toString(), 8);
|
||||
};
|
||||
|
||||
|
|
|
@ -418,3 +418,20 @@ test('invalid-file', function(t) {
|
|||
|
||||
extract.end(fs.readFileSync(fixtures.INVALID_TGZ));
|
||||
});
|
||||
|
||||
test('space prefixed', function(t) {
|
||||
t.plan(5);
|
||||
|
||||
var extract = tar.extract();
|
||||
|
||||
extract.on('entry', function(header, stream, callback) {
|
||||
t.ok(true)
|
||||
callback();
|
||||
});
|
||||
|
||||
extract.on('finish', function() {
|
||||
t.ok(true);
|
||||
});
|
||||
|
||||
extract.end(fs.readFileSync(fixtures.SPACE_TAR_GZ));
|
||||
});
|
||||
|
|
1
test/fixtures/index.js
vendored
1
test/fixtures/index.js
vendored
|
@ -8,3 +8,4 @@ exports.UNICODE_BSD_TAR = path.join(__dirname, 'unicode-bsd.tar');
|
|||
exports.UNICODE_TAR = path.join(__dirname, 'unicode.tar');
|
||||
exports.NAME_IS_100_TAR = path.join(__dirname, 'name-is-100.tar');
|
||||
exports.INVALID_TGZ = path.join(__dirname, 'invalid.tgz');
|
||||
exports.SPACE_TAR_GZ = path.join(__dirname, 'space.tar');
|
||||
|
|
BIN
test/fixtures/space.tar
vendored
Normal file
BIN
test/fixtures/space.tar
vendored
Normal file
Binary file not shown.
Loading…
Reference in a new issue