From 867f803c02d69d1dc31638bbb9423cac6b4009ea Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 12 Sep 2024 18:57:20 +0200 Subject: [PATCH] trurl: make sure URL encoded %-hex is done lowercase Match how libcurl does it. Add two tests to verify. Fixes #357 Reported-by: Peter Schilling --- tests.json | 24 ++++++++++++++++++++++++ trurl.c | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/tests.json b/tests.json index d871d178..52a8fa00 100644 --- a/tests.json +++ b/tests.json @@ -2956,5 +2956,29 @@ "stderr": "", "returncode": 0 } + }, + { + "input": { + "arguments": [ + "http://example.com/?a=%5D" + ] + }, + "expected": { + "stdout": "http://example.com/?a=%5d\n", + "stderr": "", + "returncode": 0 + } + }, + { + "input": { + "arguments": [ + "http://example.com/?a=%5D&b=%5D" + ] + }, + "expected": { + "stdout": "http://example.com/?a=%5d&b=%5d\n", + "stderr": "", + "returncode": 0 + } } ] diff --git a/trurl.c b/trurl.c index 314374dc..e8f922c1 100644 --- a/trurl.c +++ b/trurl.c @@ -1340,7 +1340,7 @@ static char *encodequery(char *str, size_t len) *dupe++ = in; else { /* encode it */ - const char hex[] = "0123456789ABCDEF"; + const char hex[] = "0123456789abcdef"; dupe[0]='%'; dupe[1] = hex[in>>4]; dupe[2] = hex[in & 0xf];