fix(artifact-tab): decode text artifacts as UTF-8 - #478
Open
moneebarif1 wants to merge 2 commits into
Open
Conversation
getTextContent() decoded base64 with a bare atob(), which produces a
Latin-1 binary string. Multibyte UTF-8 sequences were therefore
misinterpreted, so non-ASCII text artifacts (e.g. Japanese, Arabic,
emoji) rendered as mojibake in the Artifacts tab preview.
Decode the base64 into raw bytes and run them through TextDecoder('utf-8')
so multibyte content round-trips correctly. Uses TextDecoder instead of
the deprecated escape()/unescape() pair.
Adds regression tests for multibyte, ASCII, and empty-input cases.
Fixes google#452
wyf7107
approved these changes
Aug 18, 2026
Collaborator
|
hi, thanks for the PR, do you mind sync to HEAD and update this PR? |
Author
|
Done — synced the branch with the latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #452.
Text artifacts containing non-ASCII characters (Japanese, Arabic, emoji, …) rendered as mojibake in the Artifacts tab preview — e.g.
こんにちはshowed asã?"ã‚"ã?«ã?¡ã?¯.Root cause
getTextContent()inartifact-tab.component.tsdecoded the base64 payload with a bareatob().atob()returns a "binary string" where each character is a single byte, so multibyte UTF-8 sequences are misinterpreted as Latin-1 (ISO-8859-1).Fix
Decode the base64 into raw bytes and run them through
TextDecoder('utf-8'):This is the correct inverse of the UTF-8-aware encode path. I used
TextDecoderrather than thedecodeURIComponent(escape(...))idiom suggested in the issue, sinceescape/unescapeare deprecated.Testing
Added regression tests to
artifact-tab.component.spec.tscovering multibyte (こんにちは 🌙 مرحبا), ASCII, and empty-input cases. All component tests pass: