Closed thekid closed 3 years ago
Views are already sent with a charset in the content type, see here:
However, we could use xp::ENCODING
here instead of hard-wiring it.
https://webhint.io/docs/user-guide/server-configurations/apache/ lists the following file extensions for adding utf-8
to:
Extension | util.MimeType::getByFileName() | Action |
---|---|---|
.appcache | text/cache-manifest | text/* |
.atom | application/atom+xml | Listed |
.css | text/css | text/* |
.js | application/javascript | Listed |
.json | application/json | Listed |
.manifest | text/cache-manifest | text/* |
.map | application/json | Listed |
.mjs | application/javascript | Listed |
.rdf | application/rdf+xml | Listed |
.rss | application/rss+xml | Listed |
.vtt | text/vtt | text/* |
.webmanifest | application/manifest+json | Listed |
.xml | application/xml | Listed |
https://webhint.io/docs/user-guide/server-configurations/iis/ includes image/svg+xml
to include in this list.
We could also extend the rule to include application/*+xml
and application/*+json
, which would make the rule more generic.
I'm a bit reluctant to automatically set a charset parameter for XML documents, as they typically start with this line:
<?xml version="1.0" encoding="UTF-8"?>
...and this may create the situation where our Content-Type header says one thing and the XML file says something different. On the other hand, no one in his or her right mind would deliver XML files with anything other than utf-8 today, would they?
See also https://stackoverflow.com/questions/3272534/what-content-type-value-should-i-send-for-my-xml-sitemap
Motivation
Why is that important?
See https://webhint.io/docs/user-guide/hints/hint-content-type/