fix: problems with utf8 names in zip files https://github.com/rejetto/hfs/issues/64

Massimo Melina committed Jun 26, 2022 at 19:46 UTC 75fc7b383dec340f77efe2b67d7f695167de394b
1 file changed +5 -3
server/src/QuickZipStream.ts
+5 -3
@@ -13,6 +13,8 @@ import('@node-rs/crc32').then(lib => crc32function = lib.crc32, () => {
13 return crc32function = crc32lib.unsigned
14 })
15
16 +const FLAGS = 0x0808 // bit3 = no crc in local header + bit11 = utf8
17 +
18 interface ZipSource {
19 path: string
20 sourcePath?: string
@@ -105,11 +107,11 @@ export class QuickZipStream extends Readable {
107 let { path, sourcePath, getData, size, ts, mode } = file
108 const pathAsBuffer = Buffer.from(path, 'utf8')
109 const offset = this.dataWritten
108 - let version = 20
110 + const version = 20
111 this.controlledPush([
112 4, 0x04034b50,
113 2, version,
112 - 2, 0x08, // flags
114 + 2, FLAGS,
115 2, 0, // compression = store
116 ...ts2buf(ts),
117 4, 0, // crc
@@ -177,7 +179,7 @@ export class QuickZipStream extends Readable {
179 4, 0x02014b50, // central dir signature
180 2, version,
181 2, version,
180 - 2, 0x08, // flags (bit3 = no crc in local header)
182 + 2, FLAGS,
183 2, 0, // compression method = store
184 ...ts2buf(ts),
185 4, crc,