diff options
author | Shadowfacts <me@shadowfacts.net> | 2020-05-04 23:43:05 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-05 11:19:38 +0200 |
commit | fcd922f7b10be0da5b946691d33f0a61626400d7 (patch) | |
tree | ac95743cad4de158b4b46d71d5c11cc6d6d9789b /Libraries/LibWeb/DOM/HTMLFormElement.cpp | |
parent | 7f538ea7ebb87c1731a136eb7f6b94de74a6defd (diff) | |
download | serenity-fcd922f7b10be0da5b946691d33f0a61626400d7.zip |
LibWeb: Add basic URL encoder for individual values and param lists
Diffstat (limited to 'Libraries/LibWeb/DOM/HTMLFormElement.cpp')
-rw-r--r-- | Libraries/LibWeb/DOM/HTMLFormElement.cpp | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/Libraries/LibWeb/DOM/HTMLFormElement.cpp b/Libraries/LibWeb/DOM/HTMLFormElement.cpp index 8e310983f1..cabb282d3e 100644 --- a/Libraries/LibWeb/DOM/HTMLFormElement.cpp +++ b/Libraries/LibWeb/DOM/HTMLFormElement.cpp @@ -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); |