Skip to content

fix(server): serve html assets with utf-8 charset - #6409

Open
talkingdonkeyz wants to merge 1 commit into
pingdotgg:mainfrom
talkingdonkeyz:fix-html-preview-charset
Open

fix(server): serve html assets with utf-8 charset#6409
talkingdonkeyz wants to merge 1 commit into
pingdotgg:mainfrom
talkingdonkeyz:fix-html-preview-charset

Conversation

@talkingdonkeyz

@talkingdonkeyz talkingdonkeyz commented Aug 13, 2026

Copy link
Copy Markdown

What Changed

The /api/assets route served workspace HTML files with a bare text/html content type. It now sends text/html; charset=utf-8 for .html/.htm files, plus tests for the header.

Why

Opening an HTML file in the built-in browser garbles any non-ASCII text unless the file declares its own <meta charset> (agents often don't). The asset response has no charset and sets X-Content-Type-Options: nosniff, so Chromium falls back to windows-1252 and UTF-8 content renders as mojibake (你好 becomes ä½ å¥½).

HTML is the only type that needs this: CSS and module scripts already default to UTF-8, classic scripts inherit the document's encoding, and SVG is XML which is UTF-8 by default.

UI Changes

Same file served without and with the fix:

Before:

Screenshot 2026-08-13 at 01 41 15

After:

Screenshot 2026-08-13 at 01 42 10

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes (N/A)

Note

Low Risk
Narrow header change on the asset route with tests; no auth, data, or routing logic changes.

Overview
Workspace HTML files served from /api/assets now get Content-Type: text/html; charset=utf-8 for .html and .htm paths (case-insensitive), instead of a bare text/html from the file response.

That aligns asset responses with the built-in browser expectation so UTF-8 text renders correctly when pages lack their own <meta charset>, especially with X-Content-Type-Options: nosniff already set on these responses.

Tests cover .html/.htm and uppercase .HTM; SVG sandbox headers and other asset types are unchanged.

Reviewed by Cursor Bugbot for commit 9e42ae6. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Serve HTML assets with Content-Type: text/html; charset=utf-8 in assetResponseHeaders

Updates assetResponseHeaders to set Content-Type: text/html; charset=utf-8 for .html and .htm files (case-insensitive). Previously, HTML assets were served without an explicit charset, which could cause encoding issues in browsers.

Macroscope summarized 9e42ae6.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7e9ebd7e-e83c-4212-8f61-134827d4e180

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Aug 13, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved 9e42ae6

Simple bug fix adding UTF-8 charset header for HTML assets. The change follows the existing pattern for SVG files in the same function and includes test coverage.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant