Include charset in Content-Type header for all applicable standard types#1439
Include charset in Content-Type header for all applicable standard types#1439davidism merged 2 commits intopallets:masterfrom alexhenrie:0.14-maintenance
Conversation
|
I'm having trouble finding the rules about this in the link you provided. Can you provide a more specific reference? |
|
I came up with the list of application/ecmascript, application/javascript, application/news-checkgroups, application/news-groupinfo, application/sql, and application/xml through a 2-step process:
Originally I was just going to add application/javascript because that's the kind of file that I was having trouble with, but then I realized that several other types would have the same problem. |
|
I tried to verify your list, and while it looks like all the ones you listed have a charset parameter, you also missed "application/xml-dtd" and "application/xml-external-parsed-entity", where the subclass was "application/xml", since that's a subclass of "text/plain". Then I discovered that the types listed in your first and second links don't match up very well. The XDG list has 786 types, the IANA list has 1746 detail pages, and they only share 190, 108 of which start with "application/" and don't end with "+xml", and 6 of which specify a charset parameter. But if you only look at the IANA list, ignoring the fact that the types aren't in the XDG list (like you did with "application/news-checkgroups"), there are 40 "application" sub-types that have a charset parameter: DetailsSo you missed a few 😉 (how did you discover "application/news-groupinfo" but not the others?), but this list is clearly not useful for us to maintain. So I'm proposing we just use the XDG list, 6 items. If anyone needs special handling for one of these other types, they can add it to the set for their app. |
move charset list closer to get_content_type add comment about source of charset list
|
Rebased to master, added changelog and comments. |
|
Oh wow, I missed a lot. Thanks for catching Freedesktop may add some of these to their list in the future though ( Thanks for working on this! |
(charset is now added to `Content-Type` automatically, see pallets/werkzeug#1439)
The charset parameter is valid for 6 standard MIME types plus any type ending in +xml (whether or not it is an application type). Inclusion of this parameter is necessary to look at non-ASCII text files in a web browser.
See https://www.iana.org/assignments/media-types/media-types.xhtml for more information.