mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-26 17:47:19 +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:
committed by
Andreas Kling
parent
1cdccf901b
commit
b16b9709b9
@@ -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 {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user