[GH-ISSUE #658] Line 117 of index.js and garbled Chinese characters #400

Closed
opened 2026-04-08 16:52:37 +03:00 by zhus · 1 comment
Owner

Originally created by @WangShouzheng9527 on GitHub (Jan 11, 2026).
Original GitHub issue: https://github.com/sigoden/dufs/issues/658

Line 117 DATA = JSON.parse(decodeBase64($indexData.innerHTML));
Debugging revealed that the processing result of decodeBase64 is not an object
he following functions work properly when replaced

function decodeBase64(base64String) {
  // const binString = atob(base64String);
  // const len = binString.length;
  // const bytes = new Uint8Array(len);
  // const arr = new Uint32Array(bytes.buffer, 0, Math.floor(len / 4));
  // let i = 0;
  // for (; i < arr.length; i++) {
  //   arr[i] = binString.charCodeAt(i * 4) |
  //     (binString.charCodeAt(i * 4 + 1) << 8) |
  //     (binString.charCodeAt(i * 4 + 2) << 16) |
  //     (binString.charCodeAt(i * 4 + 3) << 24);
  // }
  // for (i = i * 4; i < len; i++) {
  //   bytes[i] = binString.charCodeAt(i);
  // }
  // return new TextDecoder().decode(bytes);

    const binaryString = atob(base64String);
    const bytes = new Uint8Array(binaryString.length);
    for (let i = 0; i < binaryString.length; i++) {
      bytes[i] = binaryString.charCodeAt(i);
    }
    return new TextDecoder('utf-8').decode(bytes);
}
Originally created by @WangShouzheng9527 on GitHub (Jan 11, 2026). Original GitHub issue: https://github.com/sigoden/dufs/issues/658 Line 117 DATA = JSON.parse(decodeBase64($indexData.innerHTML)); Debugging revealed that the processing result of decodeBase64 is not an object he following functions work properly when replaced ```js function decodeBase64(base64String) { // const binString = atob(base64String); // const len = binString.length; // const bytes = new Uint8Array(len); // const arr = new Uint32Array(bytes.buffer, 0, Math.floor(len / 4)); // let i = 0; // for (; i < arr.length; i++) { // arr[i] = binString.charCodeAt(i * 4) | // (binString.charCodeAt(i * 4 + 1) << 8) | // (binString.charCodeAt(i * 4 + 2) << 16) | // (binString.charCodeAt(i * 4 + 3) << 24); // } // for (i = i * 4; i < len; i++) { // bytes[i] = binString.charCodeAt(i); // } // return new TextDecoder().decode(bytes); const binaryString = atob(base64String); const bytes = new Uint8Array(binaryString.length); for (let i = 0; i < binaryString.length; i++) { bytes[i] = binaryString.charCodeAt(i); } return new TextDecoder('utf-8').decode(bytes); } ```
zhus closed this issue 2026-04-08 16:52:37 +03:00
Author
Owner

@sigoden commented on GitHub (Jan 12, 2026):

I cannot confirm the bug. There is no issue with decodeBase64.

<!-- gh-comment-id:3737301174 --> @sigoden commented on GitHub (Jan 12, 2026): I cannot confirm the bug. There is no issue with decodeBase64.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sigoden/dufs#400