urlapi: improved return codes

- add CURLUE_BACKSLASH that can be returned when a backslash was used
  where a forward one probably was intended.

- make CURLUE_NO_HOST higher priority than port number errors for URLs
  without hostname. Like in "http://::1"

- shortened some URL parser error strings

Extend test 1560 to verify.

Reported-by: kit-ty-kate on github
Fixes #22337
Closes #22408
This commit is contained in:
Daniel Stenberg 2026-07-27 16:05:38 +02:00
parent c7328740ec
commit 573a6ec16b
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
8 changed files with 54 additions and 27 deletions

View file

@ -163,20 +163,20 @@ u6: URL decode error, most likely because of rubbish in the input
u7: A memory function failed
u8: Credentials was passed in the URL when prohibited
u9: An unknown part ID was passed to a URL API function
u10: No scheme part in the URL
u11: No user part in the URL
u12: No password part in the URL
u13: No options part in the URL
u14: No host part in the URL
u15: No port part in the URL
u16: No query part in the URL
u17: No fragment part in the URL
u18: No zoneid part in the URL
u10: No scheme present
u11: No user present
u12: No password present
u13: No options present
u14: No host present
u15: No port number present
u16: No query present
u17: No fragment present
u18: No zoneid present
u19: Bad file:// URL
u20: Bad fragment
u21: Bad hostname
u22: Bad IPv6 address
u23: Bad login part
u23: Bad login
u24: Bad password
u25: Bad path
u26: Bad query
@ -185,7 +185,8 @@ u28: Unsupported number of slashes following scheme
u29: Bad user
u30: libcurl lacks IDN support
u31: A value or data field is larger than allowed
u32: CURLUcode unknown
u32: Found a backslash where a forward slash was expected
u33: CURLUcode unknown
</stdout>
</verify>

View file

@ -153,6 +153,14 @@ struct clearurlcase {
};
static const struct testcase get_parts_list[] = {
/* backslash mistakes */
{"http:\\\\hostname", "",
CURLU_GUESS_SCHEME, 0, CURLUE_BACKSLASH },
{"http:\\\\hostname:1234", "",
CURLU_GUESS_SCHEME, 0, CURLUE_BACKSLASH },
{"http://hostname:1111\\path", "",
0, 0, CURLUE_BACKSLASH },
/* non-supported URL without hostname */
{"weird:///path",
"weird | [11] | [12] | [13] | | [15] | /path | [16] | [17]",
@ -753,7 +761,7 @@ static const struct urltestcase get_url_list[] = {
/* malformed unbracketed IPv6 */
{"https://fe80:8080::1/", "", 0, 0, CURLUE_BAD_PORT_NUMBER},
{"https://::1/", "", 0, 0, CURLUE_BAD_PORT_NUMBER},
{"https://::1/", "", 0, 0, CURLUE_NO_HOST},
/* Empty host with standard schemes */
{"http:///", "", 0, 0, CURLUE_NO_HOST},