Skip to content

Commit

Permalink
Use endOfDirectory file header instead of local header
Browse files Browse the repository at this point in the history
  • Loading branch information
ZJONSSON committed Jun 1, 2019
1 parent 4b7c39c commit e81a932
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/Open/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ module.exports = function centralDirectory(source, options) {
})
.then(function(comment) {
vars.comment = comment;
vars.type = (vars.uncompressedSize === 0 && /[\/\\]$/.test(vars.path)) ? 'Directory' : 'File';
vars.stream = function(_password) {
return unzip(source, vars.offsetToLocalFileHeader,_password);
return unzip(source, vars.offsetToLocalFileHeader,_password, vars);
};
vars.buffer = function(_password) {
return BufferStream(vars.stream(_password));
Expand Down
5 changes: 4 additions & 1 deletion lib/Open/unzip.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var Buffer = require('../Buffer');
if (!Stream.Writable || !Stream.Writable.prototype.destroy)
Stream = require('readable-stream');

module.exports = function unzip(source,offset,_password) {
module.exports = function unzip(source,offset,_password, directoryVars) {
var file = PullStream(),
entry = Stream.PassThrough(),
vars;
Expand Down Expand Up @@ -44,6 +44,9 @@ module.exports = function unzip(source,offset,_password) {
.then(function(extraField) {
var checkEncryption;
vars.extra = parseExtraField(extraField, vars);
// Ignore logal file header vars if the directory vars are available
if (directoryVars && directoryVars.compressedSize) vars = directoryVars;

if (vars.flags & 0x01) checkEncryption = file.pull(12)
.then(function(header) {
if (!_password)
Expand Down

0 comments on commit e81a932

Please sign in to comment.