Skip to content

Commit

Permalink
Merge pull request #251 from warbaby/utf8_name
Browse files Browse the repository at this point in the history
fix bug when filename or path contains multi-byte characters
  • Loading branch information
cthackers authored Oct 11, 2018
2 parents 92023f7 + 82f387e commit aec5998
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion util/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ module.exports = (function() {
if (input.length === 0) {
return Buffer.alloc(0)
}
return Buffer.alloc(input.length, input, 'utf8');
return Buffer.from(input, 'utf8');
}
},

Expand Down
8 changes: 6 additions & 2 deletions zipFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,12 @@ module.exports = function (/*String|Buffer*/input, /*Number*/inputType) {
// data header
entry.header.offset = dindex;
var dataHeader = entry.header.dataHeaderToBinary();
var c = entry.entryName + entry.extra.toString();
var postHeader = Buffer.alloc(c.length, c);
var entryNameLen = entry.rawEntryName.length;
var extra = entry.extra.toString();
var postHeader = Buffer.alloc(entryNameLen + extra.length);
entry.rawEntryName.copy(postHeader, 0);
postHeader.fill(extra, entryNameLen);

var dataLength = dataHeader.length + postHeader.length + compressedData.length;

dindex += dataLength;
Expand Down

0 comments on commit aec5998

Please sign in to comment.