mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 02:03:06 -05:00
LibWeb: When creating form action URL, only include value for the submit
that was used to submit the form
This commit is contained in:
parent
5c46741be8
commit
7f538ea7eb
Notes:
sideshowbarker
2024-07-19 06:57:42 +09:00
Author: https://github.com/shadowfacts Commit: https://github.com/SerenityOS/serenity/commit/7f538ea7ebb Pull-request: https://github.com/SerenityOS/serenity/pull/2107
3 changed files with 5 additions and 4 deletions
|
@ -41,7 +41,7 @@ HTMLFormElement::~HTMLFormElement()
|
|||
{
|
||||
}
|
||||
|
||||
void HTMLFormElement::submit()
|
||||
void HTMLFormElement::submit(RefPtr<HTMLInputElement> submitter)
|
||||
{
|
||||
if (action().is_null()) {
|
||||
dbg() << "Unsupported form action ''";
|
||||
|
@ -68,7 +68,7 @@ void HTMLFormElement::submit()
|
|||
|
||||
for_each_in_subtree_of_type<HTMLInputElement>([&](auto& node) {
|
||||
auto& input = to<HTMLInputElement>(node);
|
||||
if (!input.name().is_null())
|
||||
if (!input.name().is_null() && (input.type() != "submit" || &input == submitter))
|
||||
parameters.append({ input.name(), input.value() });
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/HTMLElement.h>
|
||||
#include <LibWeb/DOM/HTMLInputElement.h>
|
||||
|
||||
namespace Web {
|
||||
|
||||
|
@ -38,7 +39,7 @@ public:
|
|||
String action() const { return attribute("action"); }
|
||||
String method() const { return attribute("method"); }
|
||||
|
||||
void submit();
|
||||
void submit(RefPtr<HTMLInputElement> submitter);
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
|
@ -63,7 +63,7 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const StyleProperties*)
|
|||
button.on_click = [this] {
|
||||
if (auto* form = first_ancestor_of_type<HTMLFormElement>()) {
|
||||
// FIXME: Remove this const_cast once we have a non-const first_ancestor_of_type.
|
||||
const_cast<HTMLFormElement*>(form)->submit();
|
||||
const_cast<HTMLFormElement*>(form)->submit(this);
|
||||
}
|
||||
};
|
||||
widget = button;
|
||||
|
|
Loading…
Add table
Reference in a new issue