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

Use UTF-8 decode without BOM for multipart/form-data #24648

Open
CYBAI opened this issue Nov 4, 2019 · 1 comment
Open

Use UTF-8 decode without BOM for multipart/form-data #24648

CYBAI opened this issue Nov 4, 2019 · 1 comment
Labels

Comments

@CYBAI
Copy link
Collaborator

@CYBAI CYBAI commented Nov 4, 2019

whatwg/fetch#915
web-platform-tests/wpt#17589

@jdm I think following code is the related function 👀?

fn run_form_data_algorithm(
root: &GlobalScope,
bytes: Vec<u8>,
mime: &[u8],
) -> Fallible<FetchedData> {
let mime_str = if let Ok(s) = str::from_utf8(mime) {
s
} else {
""
};
let mime: Mime = mime_str
.parse()
.map_err(|_| Error::Type("Inappropriate MIME-type for Body".to_string()))?;
// TODO
// ... Parser for Mime(TopLevel::Multipart, SubLevel::FormData, _)
// ... is not fully determined yet.
if mime.type_() == mime::APPLICATION && mime.subtype() == mime::WWW_FORM_URLENCODED {
let entries = form_urlencoded::parse(&bytes);
let formdata = FormData::new(None, root);
for (k, e) in entries {
formdata.Append(USVString(k.into_owned()), USVString(e.into_owned()));
}
return Ok(FetchedData::FormData(formdata));
}
Err(Error::Type("Inappropriate MIME-type for Body".to_string()))
}

@CYBAI CYBAI added the I-spec-update label Nov 4, 2019
@jdm
Copy link
Member

@jdm jdm commented Nov 4, 2019

You are correct, and it's also related to https://github.com/servo/rust-url/blob/7d2c9d6ceb3307a3fad4c4bcb7f5b07b5e24c755/src/form_urlencoded.rs#L21-L58. It's not entirely clear to me what needs to be done.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.