libfw-client 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -746,7 +746,13 @@ export class LibfwClient {
746
746
  */
747
747
  async _archiveName(path) {
748
748
  const base = (await this._cleanPath(path)).split('/').pop() || 'download';
749
- return `${base.replace(/[^\w.\- ]+/g, '_') || 'download'}.zip`;
749
+ // Strip only genuinely illegal filesystem characters. `\w` must NOT be
750
+ // used as a whitelist here: it is ASCII-only, so every non-ASCII name
751
+ // (中文, кириллица, accents, …) collapsed to `_` and the archive came out
752
+ // as `_.zip`. Path traversal is already rejected by `_safeEntryName`.
753
+ // eslint-disable-next-line no-control-regex
754
+ const safe = base.replace(/[\u0000-\u001f<>:"/\\|?*]+/g, '_').trim();
755
+ return `${safe || 'download'}.zip`;
750
756
  }
751
757
 
752
758
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libfw-client",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "High-performance streaming file & folder transfer SDK for the browser (libfw WASM engine + File System Access API + IndexedDB resume).",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/pkg/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "libfw-client",
3
3
  "type": "module",
4
4
  "description": "libfw client: native Rust client + WASM engine + JS SDK",
5
- "version": "0.4.4",
5
+ "version": "0.4.5",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
package/zip.js CHANGED
@@ -6,7 +6,10 @@
6
6
  * {@link createZip}. The archive uses the STORE method (no compression) —
7
7
  * the SDK stays dependency-free (no deflate implementation) and CPU cost is
8
8
  * negligible. Entries carry the full virtual path (with `/` separators), so
9
- * extractors recreate the folder structure automatically.
9
+ * extractors recreate the folder structure automatically. Entry names are
10
+ * UTF-8 encoded and the EFS general purpose flag (bit 11) is set in both the
11
+ * local and central headers, so non-ASCII names survive extraction on any
12
+ * platform instead of being decoded with the local OEM code page.
10
13
  *
11
14
  * @module libfw/zip
12
15
  */
@@ -74,7 +77,9 @@ export function createZip(entries) {
74
77
  const dv = new DataView(local.buffer);
75
78
  dv.setUint32(0, 0x04034b50, true); // "PK\x03\x04"
76
79
  dv.setUint16(4, 20, true); // version needed to extract
77
- dv.setUint16(6, 0, true); // general purpose flags
80
+ // Bit 11 (0x0800) = EFS: the name/comment are UTF-8. Entry names are
81
+ // always encoded with TextEncoder above, so the flag is unconditional.
82
+ dv.setUint16(6, 0x0800, true); // general purpose flags
78
83
  dv.setUint16(8, 0, true); // compression method: STORE
79
84
  dv.setUint16(10, 0, true); // last mod time
80
85
  dv.setUint16(12, 0x0021, true); // last mod date (1980-01-01)
@@ -102,7 +107,7 @@ export function createZip(entries) {
102
107
  dv.setUint32(0, 0x02014b50, true); // "PK\x01\x02"
103
108
  dv.setUint16(4, 20, true); // version made by
104
109
  dv.setUint16(6, 20, true); // version needed to extract
105
- dv.setUint16(8, 0, true); // flags
110
+ dv.setUint16(8, 0x0800, true); // flags (bit 11 = EFS, UTF-8 names)
106
111
  dv.setUint16(10, 0, true); // method: STORE
107
112
  dv.setUint16(12, 0, true); // mod time
108
113
  dv.setUint16(14, 0x0021, true); // mod date