hyperium / mime

MIMEs in Rust
https://docs.rs/mime
MIT License
179 stars 79 forks source link

Charset case may need to be preserved #116

Open pshaughn opened 4 years ago

pshaughn commented 4 years ago

https://github.com/web-platform-tests/wpt/blob/master/fetch/api/basic/scheme-data.any.js expects to see specifically uppercase US-ASCII. This may be counterintuitive given RFC 7231! Even though charset names are case-insensitive within the context of http algorithms, it seems that the web platform tests expect their string case to be preserved when a specification (RFC 2397 here) has set a specific case.

https://github.com/servo/servo is currently using this Mime class and is trying to pass WPT tests.

pshaughn commented 4 years ago

It might make sense for client code to be able ask the Mime class two distinct questions that don't always have the same answer: "What charset is this content type?" and "What is the charset= parameter of this content type?" Currently, the API only syntactically exposes the second question, and what it returns is semantically somewhere between the two questions.

CYBAI commented 1 year ago

It seems we only lowercase parameter values for "charset".

https://github.com/hyperium/mime/blob/938484de95445a2af931515d2b7252612c575da7/mime-parse/src/lib.rs#L297-L302

I wonder if we could stop this lowercase in the mime crate and let users do it when necessary. but this could be a breaking change though :/