script: Encode with requested encoding for <form enctype="multipart/form-data"> #45028
Merged
Conversation
yezhizhen
commented
May 20, 2026
Comment on lines
+1988
to
+1989
| fn encode_with_html_fallback<'a>(input: &'a str, encoding: &'static Encoding) -> Cow<'a, [u8]> { | ||
| encoding.encode(input).0 |
Member
Author
There was a problem hiding this comment.
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
TimvdLippe
reviewed
May 22, 2026
TimvdLippe
left a comment
Contributor
There was a problem hiding this comment.
I find the format macros easier to read than multiple .extend calls. I think your fix is mostly related to correct escaping now, which is great. So I think we can use format! and still have your fixes in as well?
| result.extend(b"\r\n\r\n"); | ||
|
|
||
| let mut bytes = f.upcast::<Blob>().get_bytes().unwrap_or(vec![]); | ||
| let mut bytes = f.upcast::<Blob>().get_bytes().unwrap_or_else(|_| vec![]); |
Contributor
There was a problem hiding this comment.
Nit: I am surprised clippy doesn't want this to be unwrap_or_default()?
TimvdLippe
approved these changes
May 22, 2026
TimvdLippe
enabled auto-merge
May 22, 2026 10:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Encode with requested encoding.
Implement step 2.3 of https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart/form-data-encoding-algorithm:
Testing: Existing wpt.
Part of #10778