urlapi: URL decode hostname before IP address normalization

With this, IPv6 addresses that end with '%25' with no following zone id are
considered invalid.

Extend test 1560 to verify

Reported-by: Hem Parekh
Closes #21918
This commit is contained in:
Daniel Stenberg 2026-06-09 08:18:18 +02:00
parent 8145476d5d
commit 04afd16076
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 18 additions and 10 deletions

View file

@ -626,6 +626,13 @@ static const struct testcase get_parts_list[] = {
};
static const struct urltestcase get_url_list[] = {
/* percent-encoded IP addresses */
{"https://127.0.0.%31.", "https://127.0.0.1/", 0, 0, CURLUE_OK},
{"https://127.0.0.0%78f%46.", "https://127.0.0.255/", 0, 0, CURLUE_OK},
{"https://%30%31%37%37%2e%31", "https://127.0.0.1/", 0, 0, CURLUE_OK},
{"https://[fe80%3A%3A20c%3A29ff%3Afe9c%3A409b]/",
"https://[fe80::20c:29ff:fe9c:409b]/", 0, 0, CURLUE_OK },
/* IPvFuture format */
{"http://[v1.fe80::abcd]/", "", 0, 0, CURLUE_BAD_IPV6},
@ -842,8 +849,8 @@ static const struct urltestcase get_url_list[] = {
"",
0, 0, CURLUE_BAD_IPV6},
{"https://[fe80::20c:29ff:fe9c:409b%25]:1234",
"https://[fe80::20c:29ff:fe9c:409b%2525]:1234/",
0, 0, CURLUE_OK},
"",
0, 0, CURLUE_BAD_IPV6},
{"https://[fe80::20c:29ff:fe9c:409b%eth0]:1234",
"https://[fe80::20c:29ff:fe9c:409b%25eth0]:1234/",
0, 0, CURLUE_OK},