mirror of
https://github.com/curl/curl.git
synced 2026-08-25 01:03:31 +03:00
urlapi: consume trailing dots after IPv4 numerical addresses
If the hostname is specified as an IPv4 numerical address and it is followed by a single dot, acccept that as a valid IPv4 and remove the dot when normalizing. This prevents otherwise legitimate IPv4 hostnames to have trailing dots. Seems to match what browsers do. Extended test 1560 to verify. Closes #21635
This commit is contained in:
parent
aafbe089a8
commit
831a151484
3 changed files with 40 additions and 11 deletions
|
|
@ -37,7 +37,7 @@ lib%TESTNUMBER
|
|||
success
|
||||
</stdout>
|
||||
<limits>
|
||||
Allocations: 3100
|
||||
Allocations: 3200
|
||||
</limits>
|
||||
</verify>
|
||||
</testcase>
|
||||
|
|
|
|||
|
|
@ -625,6 +625,23 @@ static const struct testcase get_parts_list[] = {
|
|||
};
|
||||
|
||||
static const struct urltestcase get_url_list[] = {
|
||||
{"https://127.1.", "https://127.0.0.1/", 0, 0, CURLUE_OK},
|
||||
{"https://127.1.:443", "https://127.0.0.1:443/", 0, 0, CURLUE_OK},
|
||||
{"https://127.1.?moo", "https://127.0.0.1/?moo", 0, 0, CURLUE_OK},
|
||||
{"https://127.1.#moo", "https://127.0.0.1/#moo", 0, 0, CURLUE_OK},
|
||||
{"https://127.1.a", "https://127.1.a/", 0, 0, CURLUE_OK},
|
||||
{"https://127.1..", "", 0, 0, CURLUE_BAD_HOSTNAME},
|
||||
{"https://127.1..:443", "", 0, 0, CURLUE_BAD_HOSTNAME},
|
||||
{"https://127.1..?moo", "", 0, 0, CURLUE_BAD_HOSTNAME},
|
||||
{"https://127.1..#moo", "", 0, 0, CURLUE_BAD_HOSTNAME},
|
||||
{"https://127.1.1.", "https://127.1.0.1/", 0, 0, CURLUE_OK},
|
||||
{"https://127.1.1./foo", "https://127.1.0.1/foo", 0, 0, CURLUE_OK},
|
||||
{"https://127.1.1.1.", "https://127.1.1.1/", 0, 0, CURLUE_OK},
|
||||
{"https://127.1", "https://127.0.0.1/", 0, 0, CURLUE_OK},
|
||||
{"https://127.0.0.1.", "https://127.0.0.1/", 0, 0, CURLUE_OK},
|
||||
{"https://127.0.0.0xff.", "https://127.0.0.255/", 0, 0, CURLUE_OK},
|
||||
{"https://127.0.0.1..", "", 0, 0, CURLUE_BAD_HOSTNAME},
|
||||
{"https://127.0.0.256..", "", 0, 0, CURLUE_BAD_HOSTNAME},
|
||||
{"http://hej./", "http://hej./", 0, 0, CURLUE_OK},
|
||||
{"http://hej../", "", 0, 0, CURLUE_BAD_HOSTNAME},
|
||||
{"http://hej.../", "", 0, 0, CURLUE_BAD_HOSTNAME},
|
||||
|
|
@ -743,9 +760,9 @@ 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://0111.02.0x3./", 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://0111.02.030./", 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://1.0xffffff", "https://1.255.255.255/", 0, 0, CURLUE_OK},
|
||||
/* IPv4 numerical overflows or syntax errors will not normalize */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue