summaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2023-04-11 17:06:54 +0200
committerDaniel Stenberg <daniel@haxx.se>2023-04-13 08:41:40 +0200
commit4cfa5bcc9ad0f7d9650bc98fed11c6189ca4c8b6 (patch)
treeeca6a86df774dea8d386eea13ae9ed0e955f1bac /lib/url.c
parent233b4e4589f38fe430af217d97252e32a30e7c31 (diff)
downloadcurl-4cfa5bcc9ad0f7d9650bc98fed11c6189ca4c8b6.tar.gz
urlapi: cleanups
- move host checks together - simplify the scheme parser loop and the end of host name parser - avoid itermediate buffer storing in multiple places - reduce scope for several variables - skip the Curl_dyn_tail() call for speed - detect IPv6 earlier and skip extra checks for such hosts - normalize directly in dynbuf instead of itermediate buffer - split out the IPv6 parser into its own funciton - call the IPv6 parser directly for ipv6 addresses - remove (unused) special treatment of % in host names - junkscan() once in the beginning instead of scattered - make junkscan return error code - remove unused query management from dedotdotify() - make Curl_parse_login_details use memchr - more use of memchr() instead of strchr() and less strlen() calls - make junkscan check and return the URL length An optimized build runs one of my benchmark URL parsing programs ~41% faster using this branch. (compared against the shipped 7.88.1 library in Debian) Closes #10935
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/lib/url.c b/lib/url.c
index 1f61edff5..3b2406212 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -2568,29 +2568,13 @@ CURLcode Curl_parse_login_details(const char *login, const size_t len,
size_t plen;
size_t olen;
- /* the input length check is because this is called directly from setopt
- and isn't going through the regular string length check */
- size_t llen = strlen(login);
- if(llen > CURL_MAX_INPUT_LENGTH)
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
/* Attempt to find the password separator */
- if(passwdp) {
- psep = strchr(login, ':');
-
- /* Within the constraint of the login string */
- if(psep >= login + len)
- psep = NULL;
- }
+ if(passwdp)
+ psep = memchr(login, ':', len);
/* Attempt to find the options separator */
- if(optionsp) {
- osep = strchr(login, ';');
-
- /* Within the constraint of the login string */
- if(osep >= login + len)
- osep = NULL;
- }
+ if(optionsp)
+ osep = memchr(login, ';', len);
/* Calculate the portion lengths */
ulen = (psep ?