summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Libraries/LibWeb/DOM/HTMLFormElement.cpp2
-rw-r--r--Libraries/LibWeb/URLEncoder.cpp24
-rw-r--r--Libraries/LibWeb/URLEncoder.h3
3 files changed, 6 insertions, 23 deletions
diff --git a/Libraries/LibWeb/DOM/HTMLFormElement.cpp b/Libraries/LibWeb/DOM/HTMLFormElement.cpp
index 5028ac0db3..397391331a 100644
--- a/Libraries/LibWeb/DOM/HTMLFormElement.cpp
+++ b/Libraries/LibWeb/DOM/HTMLFormElement.cpp
@@ -69,7 +69,7 @@ void HTMLFormElement::submit(RefPtr<HTMLInputElement> submitter)
return IterationDecision::Continue;
});
- url.set_query(url_encode(parameters));
+ url.set_query(urlencode(parameters));
// FIXME: We shouldn't let the form just do this willy-nilly.
document().frame()->page().load(url);
diff --git a/Libraries/LibWeb/URLEncoder.cpp b/Libraries/LibWeb/URLEncoder.cpp
index e760082fdc..a6be0174ea 100644
--- a/Libraries/LibWeb/URLEncoder.cpp
+++ b/Libraries/LibWeb/URLEncoder.cpp
@@ -25,34 +25,18 @@
*/
#include <AK/StringBuilder.h>
+#include <AK/URLParser.h>
#include <LibWeb/URLEncoder.h>
namespace Web {
-String url_encode(const StringView& view)
-{
- StringBuilder builder;
-
- for (char c : view) {
- if (c == ' ') {
- builder.append('+');
- } else if (c == '*' || c == '-' || c == '.' || (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || c == '_' || (c >= 'a' && c <= 'z')) {
- builder.append(c);
- } else {
- builder.appendf("%%%02X", c);
- }
- }
-
- return builder.to_string();
-}
-
-String url_encode(const Vector<URLQueryParam>& pairs)
+String urlencode(const Vector<URLQueryParam>& pairs)
{
StringBuilder builder;
for (size_t i = 0; i < pairs.size(); ++i) {
- builder.append(url_encode(pairs[i].name));
+ builder.append(urlencode(pairs[i].name));
builder.append('=');
- builder.append(url_encode(pairs[i].value));
+ builder.append(urlencode(pairs[i].value));
if (i != pairs.size() - 1)
builder.append('&');
}
diff --git a/Libraries/LibWeb/URLEncoder.h b/Libraries/LibWeb/URLEncoder.h
index 61cb8b34dd..b12cf2e29d 100644
--- a/Libraries/LibWeb/URLEncoder.h
+++ b/Libraries/LibWeb/URLEncoder.h
@@ -36,8 +36,7 @@ struct URLQueryParam {
String value;
};
-String url_encode(const StringView&);
-String url_encode(const Vector<URLQueryParam>&);
+String urlencode(const Vector<URLQueryParam>&);
}