Skip to content

fix: properly decode UTF-8 from GitHub API base64 content#2

Merged
mkobayashime merged 2 commits intomainfrom
fenc
Feb 3, 2026
Merged

fix: properly decode UTF-8 from GitHub API base64 content#2
mkobayashime merged 2 commits intomainfrom
fenc

Conversation

@mkobayashime
Copy link
Copy Markdown
Owner

@mkobayashime mkobayashime commented Feb 3, 2026

Summary

  • Fix mojibake (character corruption) in manifest.json name fields when syncing bookmarks from GitHub repositories
  • Properly decode UTF-8 encoded content from GitHub's base64 API responses

Problem

The GitHub API returns file content as base64-encoded strings. When using atob() directly to decode, multi-byte UTF-8 characters (like Japanese text) were incorrectly decoded as individual Latin-1 characters, causing garbled text in bookmark names.

Solution

Updated fetchFileContent in lib/github/api.ts to properly decode UTF-8:

  1. Decode base64 to binary string via atob()
  2. Convert binary string to Uint8Array of bytes
  3. Decode bytes as UTF-8 using TextDecoder()

Test plan

  • Create a repository with a manifest.json containing Japanese (or other multi-byte UTF-8) characters in the name field
  • Connect the repository in GitMarks
  • Sync bookmarks and verify that names display correctly without mojibake

The GitHub API returns file content as base64-encoded strings.
When using atob() directly, multi-byte UTF-8 characters (like Japanese)
were incorrectly decoded as individual Latin-1 characters, causing
mojibake in manifest.json name fields.

Fix by properly decoding: base64 → binary string → Uint8Array → UTF-8
via TextDecoder.

Fixes: #manifest-fenc
@mkobayashime mkobayashime merged commit 05e77fa into main Feb 3, 2026
1 check passed
@mkobayashime mkobayashime deleted the fenc branch February 3, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant