Serve textual files with an explicit UTF-8 charset - #381
Merged
Conversation
Stored-file responses passed the file's MIME type through verbatim, so text-like types without a charset parameter (text/plain, text/markdown, application/json, …) were served bare and browsers fell back to their default decoder — non-ASCII content rendered as mojibake when opened via the files content endpoints. A shared contentTypeWithUtf8Charset helper now appends charset=utf-8 to text-like MIME types that omit one, correctly skipping types that already declare a charset (including quoted-parameter edge cases) and leaving binary types untouched. Both the user-facing and admin stored-file routes use the helper, so downloads and inline views decode as UTF-8 everywhere. Co-authored-by: Newell Zhu <1835854+zlx@users.noreply.github.com> Co-authored-by: leixf-lab <289300866+leixf-lab@users.noreply.github.com>
This was referenced Aug 13, 2026
ReganBell
added a commit
that referenced
this pull request
Aug 13, 2026
Stored-file responses passed the file's MIME type through verbatim, so text-like types without a charset parameter (text/plain, text/markdown, application/json, …) were served bare and browsers fell back to their default decoder — non-ASCII content rendered as mojibake when opened via the files content endpoints. A shared contentTypeWithUtf8Charset helper now appends charset=utf-8 to text-like MIME types that omit one, correctly skipping types that already declare a charset (including quoted-parameter edge cases) and leaving binary types untouched. Both the user-facing and admin stored-file routes use the helper, so downloads and inline views decode as UTF-8 everywhere. <!-- codesmith:footer --> --- <a href="https://app.blacksmith.sh/yc-software/codesmith/qm/pr/381"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v2.svg"><img alt="View with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"></picture></a> <a href="https://backend.blacksmith.sh/track/enable-autofix?expires=1789237806&installation_model_id=19911&pr_number=381&repository=yc-software%2Fqm&return_to=https%3A%2F%2Fgithub.com%2Fyc-software%2Fqm%2Fpull%2F381&signature=7541e25e0bfd664c1700810b8e67601fe421866d546e8deca069758d061a32bd"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"></picture></a> <sup>Need help on this PR? Tag <code>@codesmith-bot</code> with what you need. Autofix is disabled.</sup> <!-- codesmith:autofix:disabled --> <!-- /codesmith:footer -->
ReganBell
added a commit
that referenced
this pull request
Aug 14, 2026
The recent batch of squash merges lost their Co-authored-by trailers. This commit restores the credit. Per merged PR: - #381: @zlx, @leixf-lab - #382: @lamenting-hawthorn - #383: @lamenting-hawthorn - #385: @lamenting-hawthorn - #386: @lamenting-hawthorn - #387: @ianTPE - #402: @lamenting-hawthorn - #454: @paucommit - #470: @lamenting-hawthorn - #476: @lamenting-hawthorn, @Dhevenddra, @Saidheerajgollu, @mariohercules, @foxytanuki - #481: @Luke20w, @KateZhang98, @AdamSEY, @rsindall - #482: @lucassz - #494: @salluexez, @SomSamantray, @gregario, @yoldaolmak, @lamenting-hawthorn - #512: @wooheum-xin, @Jackallink, @ianTPE, @lmo-selected, @xieqian0816, @hugo2046 - #515: @mariohercules, @Luke20w, @tchudleigh1, @Restry Co-authored-by: adamsey <adam.lababidi@gmx.com> Co-authored-by: Dhevenddra <dhevg20020402@gmail.com> Co-authored-by: foxytanuki <biz@foxytanuki.dev> Co-authored-by: Greg Jackson <gregj64@gmail.com> Co-authored-by: hugo <shen.lan123@gmail.com> Co-authored-by: Ian Chou <33033541+ianTPE@users.noreply.github.com> Co-authored-by: Jackallink <61698219+Jackallink@users.noreply.github.com> Co-authored-by: KateZhang98 <kate@tinyfish.io> Co-authored-by: Hawthorn <rv.help23@gmail.com> Co-authored-by: leixf-lab <289300866+leixf-lab@users.noreply.github.com> Co-authored-by: lmo-selected <lmo-selected@users.noreply.github.com> Co-authored-by: lucassz <4793515+lucassz@users.noreply.github.com> Co-authored-by: Luke20w <weidnerluke@gmail.com> Co-authored-by: Mario <643672+mariohercules@users.noreply.github.com> Co-authored-by: Pau Garcia <193717438+paucommit@users.noreply.github.com> Co-authored-by: Restry <restry@users.noreply.github.com> Co-authored-by: rsindall <rsindall@users.noreply.github.com> Co-authored-by: Sai Dheeraj Gollu <saidheeraj.gollu@sjsu.edu> Co-authored-by: Mohd Salauddin <sallumalik1111@gmail.com> Co-authored-by: Som Samantray <92726151+SomSamantray@users.noreply.github.com> Co-authored-by: Tom <tchudleigh1@gmail.com> Co-authored-by: Wooheum Xin <xin98@naver.com> Co-authored-by: xieqian0816 <260077733+xieqian0816@users.noreply.github.com> Co-authored-by: yoldaolmak <159899613+yoldaolmak@users.noreply.github.com> Co-authored-by: Newell Zhu <zlx.star@gmail.com>
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.
Stored-file responses passed the file's MIME type through verbatim, so text-like types without a charset parameter (text/plain, text/markdown, application/json, …) were served bare and browsers fell back to their default decoder — non-ASCII content rendered as mojibake when opened via the files content endpoints. A shared contentTypeWithUtf8Charset helper now appends charset=utf-8 to text-like MIME types that omit one, correctly skipping types that already declare a charset (including quoted-parameter edge cases) and leaving binary types untouched. Both the user-facing and admin stored-file routes use the helper, so downloads and inline views decode as UTF-8 everywhere.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.