urlapi: use uppercase hex encoding

For consistency. RFC 3986 section 2.1 says:

  "URI producers and normalizers should use uppercase hexadecimal digits
  for all percent-encodings."

Reported-by: Jeroen Ooms
Fixes #17685
Closes #17739
This commit is contained in:
Daniel Stenberg 2025-06-25 08:14:58 +02:00
parent 4c5672774f
commit b5593a6fe0
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
7 changed files with 24 additions and 27 deletions

View file

@ -242,14 +242,14 @@ static const struct testcase get_parts_list[] ={
{"https://"
"%e2%84%82%e1%b5%a4%e2%93%87%e2%84%92%e3%80%82%f0%9d%90%92%f0%9f%84%b4",
"https | [11] | [12] | [13] | "
"%e2%84%82%e1%b5%a4%e2%93%87%e2%84%92%e3%80%82%f0%9d%90%92%f0%9f%84%b4 "
"%E2%84%82%E1%B5%A4%E2%93%87%E2%84%92%E3%80%82%F0%9D%90%92%F0%9F%84%B4 "
"| [15] | / | [16] | [17]",
0, CURLU_URLENCODE, CURLUE_OK},
{"https://"
"\xe2\x84\x82\xe1\xb5\xa4\xe2\x93\x87\xe2\x84\x92"
"\xe3\x80\x82\xf0\x9d\x90\x92\xf0\x9f\x84\xb4",
"https | [11] | [12] | [13] | "
"%e2%84%82%e1%b5%a4%e2%93%87%e2%84%92%e3%80%82%f0%9d%90%92%f0%9f%84%b4 "
"%E2%84%82%E1%B5%A4%E2%93%87%E2%84%92%E3%80%82%F0%9D%90%92%F0%9F%84%B4 "
"| [15] | / | [16] | [17]",
0, CURLU_URLENCODE, CURLUE_OK},
{"https://user@example.net?he l lo",
@ -651,7 +651,7 @@ static const struct urltestcase get_url_list[] = {
{"http://example.com%2F127.0.0.1/", "", 0, 0, CURLUE_BAD_HOSTNAME},
{"https://%41", "https://A/", 0, 0, CURLUE_OK},
{"https://%20", "", 0, 0, CURLUE_BAD_HOSTNAME},
{"https://%41%0d", "", 0, 0, CURLUE_BAD_HOSTNAME},
{"https://%41%0D", "", 0, 0, CURLUE_BAD_HOSTNAME},
{"https://%25", "", 0, 0, CURLUE_BAD_HOSTNAME},
{"https://_%c0_", "https://_\xC0_/", 0, 0, CURLUE_OK},
{"https://_%c0_", "https://_%C0_/", 0, CURLU_URLENCODE, CURLUE_OK},
@ -913,11 +913,11 @@ static const struct setcase set_parts_list[] = {
0, 0, CURLUE_OK, CURLUE_OK},
{"https://example.com/",
"path=one\ntwo,",
"https://example.com/one%0atwo",
"https://example.com/one%0Atwo",
0, CURLU_URLENCODE, CURLUE_OK, CURLUE_OK},
{"https://example.com/",
"path=one\rtwo,",
"https://example.com/one%0dtwo",
"https://example.com/one%0Dtwo",
0, CURLU_URLENCODE, CURLUE_OK, CURLUE_OK},
{"https://example.com/",
"host=%43url.se,",
@ -1001,7 +1001,7 @@ static const struct setcase set_parts_list[] = {
{"https://example.com/",
"query=Al2cO3tDkcDZ3EWE5Lh+LX8TPHs,", /* contains '+' */
"https://example.com/?Al2cO3tDkcDZ3EWE5Lh%2bLX8TPHs",
"https://example.com/?Al2cO3tDkcDZ3EWE5Lh%2BLX8TPHs",
CURLU_URLDECODE, /* decode on get */
CURLU_URLENCODE, /* encode on set */
CURLUE_OK, CURLUE_OK},
@ -1063,7 +1063,7 @@ static const struct setcase set_parts_list[] = {
0, 0, CURLUE_OK, CURLUE_OK},
{NULL,
"scheme=https,user= @:,host=foobar,",
"https://%20%20%20%40%3a@foobar/",
"https://%20%20%20%40%3A@foobar/",
0, CURLU_URLENCODE, CURLUE_OK, CURLUE_OK},
/* Setting a host name with spaces is not OK: */
{NULL,
@ -1076,7 +1076,7 @@ static const struct setcase set_parts_list[] = {
0, CURLU_URLENCODE, CURLUE_OK, CURLUE_OK},
{NULL,
"scheme=https,host=foobar,path=\xc3\xa4\xc3\xb6\xc3\xbc,",
"https://foobar/%c3%a4%c3%b6%c3%bc",
"https://foobar/%C3%A4%C3%B6%C3%BC",
0, CURLU_URLENCODE, CURLUE_OK, CURLUE_OK},
{"imap://user:secret;opt@host/",
"options=updated,scheme=imaps,password=p4ssw0rd,",
@ -1598,7 +1598,7 @@ static int get_parts(void)
static const struct querycase append_list[] = {
{"HTTP://test/?s", "name=joe\x02", "http://test/?s&name=joe%02",
0, CURLU_URLENCODE, CURLUE_OK},
{"HTTP://test/?size=2#f", "name=joe=", "http://test/?size=2&name=joe%3d#f",
{"HTTP://test/?size=2#f", "name=joe=", "http://test/?size=2&name=joe%3D#f",
0, CURLU_URLENCODE, CURLUE_OK},
{"HTTP://test/?size=2#f", "name=joe doe",
"http://test/?size=2&name=joe+doe#f",