wellawaretech/node-zipstream — Issue #4: Non-ASCII file names are not handled correctly
Author: papandreou
Created: 2012-02-19 23:00:44+00:00
State: open

Non-ASCII file names come out as garbage when the file is unzipped. I skimmed the zip specification, and it seems like there has to be an extra "Unicode Path Extra Field (0x7075)" block for non-IBM Code Page 437 file names to be used.

I also noticed that `buf` might overflow because `file.name.length` gives number of characters in the string, whereas `buf.write` writes the UTF-8 encoded octets:

var buf = new Buffer(30+file.name.length);
[...]
buf.writeUInt16LE(file.name.length, 26); // file name length
buf.writeUInt16LE(0, 28); // extra field length
buf.write(file.name, 30); // file name

And in another place:

buf.writeUInt16LE(file.name.length, ptr+28); // file name length
[...]
buf.write(file.name, ptr+46); // file name