urlapi: provide more detailed return codes

Previously, the return code CURLUE_MALFORMED_INPUT was used for almost
30 different URL format violations. This made it hard for users to
understand why a particular URL was not acceptable. Since the API cannot
point out a specific position within the URL for the problem, this now
instead introduces a number of additional and more fine-grained error
codes to allow the API to return more exactly in what "part" or section
of the URL a problem was detected.

Also bug-fixes curl_url_get() with CURLUPART_ZONEID, which previously
returned CURLUE_OK even if no zoneid existed.

Test cases in 1560 have been adjusted and extended. Tests 1538 and 1559
have been updated.

Updated libcurl-errors.3 and curl_url_strerror() accordingly.

Closes #8049
This commit is contained in:
Daniel Stenberg 2021-11-23 17:07:31 +01:00
parent a5f5687368
commit 4183b8fe9a
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
8 changed files with 289 additions and 111 deletions

View file

@ -155,22 +155,34 @@ s6: CURLSHcode unknown
u0: No error
u1: An invalid CURLU pointer was passed as argument
u2: An invalid 'part' argument was passed as argument
u3: A malformed input was passed to a URL API function
u4: The port number was not a decimal number between 0 and 65535
u3: Malformed input to a URL function
u4: Port number was not a decimal number between 0 and 65535
u5: This libcurl build doesn't support the given URL scheme
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: There is no scheme part in the URL
u11: There is no user part in the URL
u12: There is no password part in the URL
u13: There is no options part in the URL
u14: There is no host part in the URL
u15: There is no port part in the URL
u16: There is no query part in the URL
u17: There is no fragment part in the URL
u18: CURLUcode unknown
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
u19: Bad file:// URL
u20: Bad fragment
u21: Bad hostname
u22: Bad IPv6 address
u23: Bad login part
u24: Bad password
u25: Bad path
u26: Bad query
u27: Bad scheme
u28: Unsupported number of slashes
u29: Bad user
u30: CURLUcode unknown
</stdout>
</verify>

View file

@ -35,9 +35,9 @@ Set excessive URL lengths
<stdout>
CURLOPT_URL 10000000 bytes URL == 43
CURLOPT_POSTFIELDS 10000000 bytes data == 0
CURLUPART_URL 10000000 bytes URL == 3 (A malformed input was passed to a URL API function)
CURLUPART_SCHEME 10000000 bytes scheme == 3 (A malformed input was passed to a URL API function)
CURLUPART_USER 10000000 bytes user == 3 (A malformed input was passed to a URL API function)
CURLUPART_URL 10000000 bytes URL == 3 (Malformed input to a URL function)
CURLUPART_SCHEME 10000000 bytes scheme == 27 (Bad scheme)
CURLUPART_USER 10000000 bytes user == 3 (Malformed input to a URL function)
</stdout>
</verify>