urlapi: accept 0X prefix in IPv4 address as well

Extend test 1560 accordingly

Closes #21820
This commit is contained in:
Daniel Stenberg 2026-05-31 23:23:45 +02:00
parent 780ccb256e
commit 1b6724882c
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 4 additions and 1 deletions

View file

@ -520,7 +520,7 @@ UNITTEST int ipv4_normalize(struct dynbuf *host)
int rc;
curl_off_t l;
if(*c == '0') {
if(c[1] == 'x') {
if(Curl_raw_tolower(c[1]) == 'x') {
c += 2; /* skip the prefix */
rc = curlx_str_hex(&c, &l, UINT_MAX);
if(rc)

View file

@ -706,6 +706,7 @@ static const struct urltestcase get_url_list[] = {
{"https://0xffffffff", "https://255.255.255.255/", 0, 0, CURLUE_OK},
{"https://1.0x1000000", "https://1.0x1000000/", 0, 0, CURLUE_OK},
{"https://0x7f.1", "https://127.0.0.1/", 0, 0, CURLUE_OK},
{"https://0X7F.1", "https://127.0.0.1/", 0, 0, CURLUE_OK},
{"https://1.2.3.256.com", "https://1.2.3.256.com/", 0, 0, CURLUE_OK},
{"https://10.com", "https://10.com/", 0, 0, CURLUE_OK},
{"https://1.2.com", "https://1.2.com/", 0, 0, CURLUE_OK},
@ -765,10 +766,12 @@ static const struct urltestcase get_url_list[] = {
{"https://16843009", "https://1.1.1.1/", 0, 0, CURLUE_OK},
{"https://0177.1", "https://127.0.0.1/", 0, 0, CURLUE_OK},
{"https://0111.02.0x3", "https://73.2.0.3/", 0, 0, CURLUE_OK},
{"https://0111.02.0X3", "https://73.2.0.3/", 0, 0, CURLUE_OK},
{"https://0111.02.0x3.", "https://73.2.0.3/", 0, 0, CURLUE_OK},
{"https://0111.02.030", "https://73.2.0.24/", 0, 0, CURLUE_OK},
{"https://0111.02.030.", "https://73.2.0.24/", 0, 0, CURLUE_OK},
{"https://0xff.0xff.0377.255", "https://255.255.255.255/", 0, 0, CURLUE_OK},
{"https://0XFF.0XFF.0377.255", "https://255.255.255.255/", 0, 0, CURLUE_OK},
{"https://1.0xffffff", "https://1.255.255.255/", 0, 0, CURLUE_OK},
/* IPv4 numerical overflows or syntax errors will not normalize */
{"https://a127.0.0.1", "https://a127.0.0.1/", 0, 0, CURLUE_OK},