mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-07 11:42:51 +00:00
LibWeb: Include the Content-Type boundary directive in form submissions
The spec requires that "multipart/form-data" Content-Type headers also include a boundary directive. This allows the content server to validate the submitted form data. Google Lens, for example, rejects forms missing this directive.
This commit is contained in:
parent
1cdccf901b
commit
b16b9709b9
Notes:
github-actions[bot]
2024-08-22 12:22:09 +00:00
Author: https://github.com/trflynn89
Commit: b16b9709b9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1158
Reviewed-by: https://github.com/shannonbooth
3 changed files with 27 additions and 6 deletions
|
@ -747,6 +747,7 @@ ErrorOr<void> HTMLFormElement::submit_as_entity_body(URL::URL parsed_action, Vec
|
|||
// 1. Assert: method is POST.
|
||||
|
||||
POSTResource::RequestContentType mime_type {};
|
||||
Vector<POSTResource::Directive> mime_type_directives;
|
||||
ByteBuffer body;
|
||||
|
||||
// 2. Switch on enctype:
|
||||
|
@ -775,6 +776,7 @@ ErrorOr<void> HTMLFormElement::submit_as_entity_body(URL::URL parsed_action, Vec
|
|||
// 2. Let mimeType be the isomorphic encoding of the concatenation of "multipart/form-data; boundary=" and the multipart/form-data
|
||||
// boundary string generated by the multipart/form-data encoding algorithm.
|
||||
mime_type = POSTResource::RequestContentType::MultipartFormData;
|
||||
mime_type_directives.empend("boundary"sv, move(body_and_mime_type.boundary));
|
||||
break;
|
||||
}
|
||||
case EncodingTypeAttributeState::PlainText: {
|
||||
|
@ -796,7 +798,7 @@ ErrorOr<void> HTMLFormElement::submit_as_entity_body(URL::URL parsed_action, Vec
|
|||
}
|
||||
|
||||
// 3. Plan to navigate to parsed action given a POST resource whose request body is body and request content-type is mimeType.
|
||||
plan_to_navigate_to(parsed_action, POSTResource { .request_body = move(body), .request_content_type = mime_type }, target_navigable, history_handling, user_involvement);
|
||||
plan_to_navigate_to(parsed_action, POSTResource { .request_body = move(body), .request_content_type = mime_type, .request_content_type_directives = move(mime_type_directives) }, target_navigable, history_handling, user_involvement);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue