tar-stream
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -71,7 +71,7 @@ var ZEROS = '0000000000000000000'; | ||
var indexOf = function(block, num, offset) { | ||
for (; offset < block.length; offset++) { | ||
var indexOf = function(block, num, offset, end) { | ||
for (; offset < end; offset++) { | ||
if (block[offset] === num) return offset; | ||
} | ||
return -1; | ||
return end; | ||
}; | ||
@@ -92,7 +92,7 @@ | ||
var decodeOct = function(val, offset) { | ||
return parseInt(val.slice(offset, clamp(indexOf(val, 32, offset), val.length, val.length)).toString(), 8); | ||
return parseInt(val.slice(offset, clamp(indexOf(val, 32, offset, val.length), val.length, val.length)).toString(), 8); | ||
}; | ||
var decodeStr = function(val, offset) { | ||
return val.slice(offset, indexOf(val, 0, offset)).toString(); | ||
var decodeStr = function(val, offset, length) { | ||
return val.slice(offset, indexOf(val, 0, offset, offset+length)).toString(); | ||
}; | ||
@@ -183,3 +183,3 @@ | ||
var name = decodeStr(buf, 0); | ||
var name = decodeStr(buf, 0, 100); | ||
var mode = decodeOct(buf, 100); | ||
@@ -190,9 +190,9 @@ var uid = decodeOct(buf, 108); | ||
var mtime = decodeOct(buf, 136); | ||
var linkname = buf[157] === 0 ? null : decodeStr(buf, 157); | ||
var uname = decodeStr(buf, 265); | ||
var gname = decodeStr(buf, 297); | ||
var linkname = buf[157] === 0 ? null : decodeStr(buf, 157, 100); | ||
var uname = decodeStr(buf, 265, 32); | ||
var gname = decodeStr(buf, 297, 32); | ||
var devmajor = decodeOct(buf, 329); | ||
var devminor = decodeOct(buf, 337); | ||
if (buf[345]) name = decodeStr(buf, 345)+'/'+name; | ||
if (buf[345]) name = decodeStr(buf, 345, 155)+'/'+name; | ||
@@ -199,0 +199,0 @@ if (cksum(buf) !== decodeOct(buf, 148)) return null; |
{ | ||
"name": "tar-stream", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "tar-stream is a streaming tar parser and generator and nothing else. It is streams2 and operates purely using streams which means you can easily extract/parse tarballs without ever hitting the file system.", | ||
@@ -5,0 +5,0 @@ "repository": "git://github.com:mafintosh/tar-stream.git", |
@@ -386,2 +386,23 @@ var test = require('tap').test; | ||
extract.end(fs.readFileSync(fixtures.UNICODE_TAR)); | ||
}); | ||
test('name-is-100', function(t) { | ||
t.plan(3); | ||
var extract = tar.extract(); | ||
extract.on('entry', function(header, stream, callback) { | ||
t.same(header.name.length, 100); | ||
stream.pipe(concat(function(data) { | ||
t.same(data.toString(), 'hello\n'); | ||
callback(); | ||
})); | ||
}); | ||
extract.on('finish', function() { | ||
t.ok(true); | ||
}); | ||
extract.end(fs.readFileSync(fixtures.NAME_IS_100_TAR)); | ||
}); |
@@ -9,1 +9,2 @@ var path = require('path'); | ||
exports.UNICODE_TAR = path.join(__dirname, 'unicode.tar'); | ||
exports.NAME_IS_100_TAR = path.join(__dirname, 'name-is-100.tar'); |
60969
18
921