mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-21 07:06:04 +00:00
LibWeb: Add basic URL encoder for individual values and param lists
This commit is contained in:
committed by
Andreas Kling
parent
7f538ea7eb
commit
fcd922f7b1
@@ -29,6 +29,7 @@
|
||||
#include <LibWeb/DOM/HTMLInputElement.h>
|
||||
#include <LibWeb/Frame.h>
|
||||
#include <LibWeb/HtmlView.h>
|
||||
#include <LibWeb/URLEncoder.h>
|
||||
|
||||
namespace Web {
|
||||
|
||||
@@ -59,12 +60,7 @@ void HTMLFormElement::submit(RefPtr<HTMLInputElement> submitter)
|
||||
|
||||
URL url(document().complete_url(action()));
|
||||
|
||||
struct NameAndValue {
|
||||
String name;
|
||||
String value;
|
||||
};
|
||||
|
||||
Vector<NameAndValue> parameters;
|
||||
Vector<URLQueryParam> parameters;
|
||||
|
||||
for_each_in_subtree_of_type<HTMLInputElement>([&](auto& node) {
|
||||
auto& input = to<HTMLInputElement>(node);
|
||||
@@ -73,15 +69,7 @@ void HTMLFormElement::submit(RefPtr<HTMLInputElement> submitter)
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
StringBuilder builder;
|
||||
for (size_t i = 0; i < parameters.size(); ++i) {
|
||||
builder.append(parameters[i].name);
|
||||
builder.append('=');
|
||||
builder.append(parameters[i].value);
|
||||
if (i != parameters.size() - 1)
|
||||
builder.append('&');
|
||||
}
|
||||
url.set_query(builder.to_string());
|
||||
url.set_query(url_encode(parameters));
|
||||
|
||||
// FIXME: We shouldn't let the form just do this willy-nilly.
|
||||
document().frame()->html_view()->load(url);
|
||||
|
||||
Reference in New Issue
Block a user