From cf93928fe9cb4ce1600f2f472191ce88e94ee0d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= jaakko.keranen@iki.fi
Date: Thu, 24 Dec 2020 23:04:28 +0200
Subject: [PATCH 1/1] Fixed percent-encoding the query string
Good old mutable vs. non-mutable argument confusion. The encoded return value was ignored (and leaked).
res/about/version.gmi | 1 +
src/gmrequest.c | 4 +++-
src/ui/documentwidget.c | 5 +++--
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/res/about/version.gmi b/res/about/version.gmi
index 42fdfba0..153882c7 100644
--- a/res/about/version.gmi
+++ b/res/about/version.gmi
@@ -7,6 +7,7 @@
+* Fixed percent-encoding of the query string.
diff --git a/src/gmrequest.c b/src/gmrequest.c
index 3eb57cec..5b005fbb 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -515,7 +515,9 @@ void submit_GmRequest(iGmRequest *d) {
set_Atomic(&d->allowUpdate, iTrue);
iGmResponse *resp = d->resp;
clear_GmResponse(resp);
-// printf("[GmRequest] URL: %s\n", cstr_String(&d->url));
+#if !defined (NDEBUG)
+#endif
iUrl url;
init_Url(&url, &d->url);
/* Check for special schemes. */
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 1830239a..bc9dbc8d 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1622,8 +1622,8 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
return iTrue;
}
else if (equal_Command(cmd, "document.input.submit") && document_App() == d) {
iString *value = collect_String(suffix_Command(cmd, "value"));
urlEncode_String(value);
iString *value = suffix_Command(cmd, "value");
set_String(value, collect_String(urlEncode_String(value)));
iString *url = collect_String(copy_String(d->mod.url));
const size_t qPos = indexOfCStr_String(url, "?");
if (qPos != iInvalidPos) {
@@ -1632,6 +1632,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
appendCStr_String(url, "?");
append_String(url, value);
postCommandf_App("open url:%s", cstr_String(url));
delete_String(value);
return iTrue;
}
else if (equal_Command(cmd, "valueinput.cancelled") &&
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).