aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-04-30 23:43:10 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-05-01 04:13:25 +0200
commit7d1e41f9c51bc1525e5b0c86b9832562d65675c1 (patch)
treea44bee148f1b5176e9e3a7be5dee18a2cc88157b /main.c
parent291d951ee1428955179a5f3ed4435c1538045651 (diff)
downloadslcl-7d1e41f9c51bc1525e5b0c86b9832562d65675c1.tar.gz
http.c: Decode URL resource and parameters separately
Given the following contrived example request: /example%FB%DC&arg%DE1=examplevalue%AA slcl must decode each token separately, so that percent-encoded characters '&', '=' or '?' do not get accidently intepreted.
Diffstat (limited to 'main.c')
-rw-r--r--main.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/main.c b/main.c
index c7481d0..4a9dfa5 100644
--- a/main.c
+++ b/main.c
@@ -150,10 +150,11 @@ static int append_form(struct form **const forms, const char **const s,
*forms = fs;
f = &(*forms)[(*n)++];
+ /* HTML input forms use '+' for whitespace, rather than %20. */
*f = (const struct form)
{
- .key = http_decode_url(key),
- .value = http_decode_url(value)
+ .key = http_decode_url(key, true),
+ .value = http_decode_url(value, true)
};
if (!f->key || !f->value)
@@ -162,14 +163,6 @@ static int append_form(struct form **const forms, const char **const s,
goto end;
}
- /* HTML input forms use '+' for whitespace, rather than %20. */
- {
- char *c = f->value;
-
- while ((c = strchr(c, '+')))
- *c = ' ';
- }
-
*s = end;
ret = 0;