Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Charset case may need to be preserved #116

Open
pshaughn opened this issue Nov 26, 2019 · 2 comments
Open

Charset case may need to be preserved #116

pshaughn opened this issue Nov 26, 2019 · 2 comments

Comments

@pshaughn
Copy link

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
Copy link
Author

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
Copy link

CYBAI commented Mar 1, 2023

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

mime/mime-parse/src/lib.rs

Lines 297 to 302 in 938484d

// Since we just converted this part of the string to lowercase,
// we can skip the `Name == &str` unicase check and do a faster
// memcmp instead.
if &owned[range(name)] == "charset" {
owned[range(value)].make_ascii_lowercase();
}

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 :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants