From fcd922f7b10be0da5b946691d33f0a61626400d7 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 4 May 2020 23:43:05 -0400 Subject: LibWeb: Add basic URL encoder for individual values and param lists --- Libraries/LibWeb/DOM/HTMLFormElement.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'Libraries/LibWeb/DOM/HTMLFormElement.cpp') 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 #include #include +#include namespace Web { @@ -59,12 +60,7 @@ void HTMLFormElement::submit(RefPtr submitter) URL url(document().complete_url(action())); - struct NameAndValue { - String name; - String value; - }; - - Vector parameters; + Vector parameters; for_each_in_subtree_of_type([&](auto& node) { auto& input = to(node); @@ -73,15 +69,7 @@ void HTMLFormElement::submit(RefPtr 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); -- cgit v1.2.3