GitHub Pages serves .yaml as text/yaml with no charset, so browsers mis-decode UTF-8
#204454
Replies: 2 comments
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
|
This looks like a genuine Pages-side MIME/charset issue, and the reproduction you've provided makes the root cause pretty clear. The important part is that the YAML bytes themselves are valid UTF-8, while the response is being served as I also agree that
What makes this particularly convincing is the comparison with The lack of a I'd consider this a solid bug report rather than expected browser behavior. The reproduction URL, Hopefully the Pages team can fix this at the MIME mapping layer; it should be a relatively small change with a meaningful impact for sites publishing human-readable YAML. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
GitHub Pages serves
.yamlfiles ascontent-type: text/yamlwith nocharsetparameter. Because atext/*response without a charset falls back to the browser's legacy locale encoding (windows-1252 in en-US), every non-ASCII character in a served YAML file is mis-decoded. The bytes are correct UTF-8; only the header is missing.Reproduction
https://masiarek.github.io/star-voting-library/03_STAR_PR/02_Examples/cases/lackner_skowron_shadow_star_pr_c7_b12.yaml
The file contains the line
count_separator: "√ó"(U+00D7 MULTIPLICATION SIGN). Browsers display:The bytes served are correct.
curlconfirms UTF-8c3 97:The browser reports the fallback itself. Evaluated on the live page:
C3→Ã,97→—(em dash in windows-1252). Hence×.This is inconsistent with GitHub's own behavior elsewhere
Every other text type on the same Pages host gets a charset, and the same
.yamlfile gets one from GitHub's raw host:content-type*.github.io.yamltext/yaml*.github.io.htmltext/html; charset=utf-8*.github.io.txttext/plain; charset=utf-8*.github.io.jsonapplication/json; charset=utf-8*.github.io.jsapplication/javascript; charset=utf-8*.github.io.csstext/css; charset=utf-8raw.githubusercontent.com.yamltext/plain; charset=utf-8.yamlis the only type I could find that misses it, so this looks like a single missing parameter in one MIME-map entry rather than a design decision.Precedent: this exact defect was already fixed for
.jsgithub/pages-gem#52 (Feb 2014) reported the identical failure for a JavaScript file — a stray
Âbefore a degree symbol, correct UTF-8 in the repo, mis-decoded by the browser because the response carried no charset. Pages now serves.jsasapplication/javascript; charset=utf-8, so that report was acted on..yamlis the same bug in the same map, still open.(Searched the Community discussions and the web before posting; the only prior report I found is the 2014
.jsone above, which is closed and concerns a different file type.)Requested fix
Serve
.yaml/.ymlas:Please do not "fix" this by switching to
application/yaml. RFC 9512 registersapplication/yamland lists its optional parameters as "N/A; unrecognized parameters should be ignored" with encoding considerations "binary" — so it cannot carry a charset, and browsers would download the file instead of rendering it. For a documentation site that publishes YAML as readable source, that is a regression.text/yamlis not itself an IANA-registered type, but since it is what Pages already sends and it renders in-browser, adding the charset parameter is the minimal, behavior-preserving fix.Impact
Any Pages site publishing YAML as viewable source. On the site above, 590 of 661
.yamlfiles contain an em dash and 475 contain×; a 3-byte character such as—,→or≥garbles into three characters (—,→,≥), so it is mostly prose that becomes unreadable, not just the odd symbol.There is no workaround available to the site owner: Pages supports no custom-header mechanism (no
_headersfile), and the alternatives — adding a UTF-8 BOM to every file, or renaming the extension — either corrupt downstream tooling or break permanent URLs.All reactions