Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions node_stream_zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const consts = {
ID_IBM1: 0x0065,
ID_IBM2: 0x0066,
ID_POSZIP: 0x4690,
ID_UNICODE_PATH: 0x7075,

EF_ZIP64_OR_32: 0xffffffff,
EF_ZIP64_OR_16: 0xffff,
Expand Down Expand Up @@ -910,10 +911,24 @@ class ZipEntry {
if (consts.ID_ZIP64 === signature) {
this.parseZip64Extra(data, offset, size);
}
if (consts.ID_UNICODE_PATH === signature) {
this.parseUnicodeFileName(data, offset, size);
}
offset += size;
}
}

parseUnicodeFileName(data, offset, length) {
readUInt8(data, offset) // version
offset += 1
length -= 1
var nameCRC32 = readUInt32LE(data, offset)
offset += 4
length -= 4
const nameData = data.slice(offset, (offset += length));
this.name = nameData.toString('utf-8')
}

parseZip64Extra(data, offset, length) {
if (length >= 8 && this.size === consts.EF_ZIP64_OR_32) {
this.size = readUInt64LE(data, offset);
Expand Down Expand Up @@ -1207,4 +1222,12 @@ function readUInt64LE(buffer, offset) {
return buffer.readUInt32LE(offset + 4) * 0x0000000100000000 + buffer.readUInt32LE(offset);
}

function readUInt32LE(buffer, offset) {
return buffer.readUInt32LE(offset);
}

function readUInt8(buffer, offset) {
return buffer.readUInt8(offset)
}

module.exports = StreamZip;