mirror of
https://github.com/curl/curl.git
synced 2026-07-10 06:57:16 +03:00
urlapi: make two #defines instead of magic values/strings in code
Closes #22181
This commit is contained in:
parent
cff59ddf4a
commit
fdbc5beed3
1 changed files with 7 additions and 3 deletions
10
lib/urlapi.c
10
lib/urlapi.c
|
|
@ -53,6 +53,10 @@
|
|||
|
||||
/* scheme is not URL encoded, the longest libcurl supported ones are... */
|
||||
#define MAX_SCHEME_LEN 40
|
||||
#define MAX_ZONEID_LEN 16
|
||||
|
||||
/* characters not allowed in hostnames */
|
||||
#define HOSTNAME_INVALID_CHARS " \r\n\t/:#?!@{}[]\\$\'\"^`*<>=;,+&()%|"
|
||||
|
||||
/*
|
||||
* If USE_IPV6 is disabled, we still want to parse IPv6 addresses, so make
|
||||
|
|
@ -425,13 +429,13 @@ UNITTEST CURLUcode ipv6_parse(struct Curl_URL *u, char *hostname,
|
|||
hlen = len;
|
||||
if(hostname[len] == '%') {
|
||||
/* this could now be '%[zone id]' */
|
||||
char zoneid[16];
|
||||
char zoneid[MAX_ZONEID_LEN];
|
||||
int i = 0;
|
||||
char *h = &hostname[len + 1];
|
||||
/* pass '25' if present and is a URL encoded percent sign */
|
||||
if(!strncmp(h, "25", 2) && h[2] && (h[2] != ']'))
|
||||
h += 2;
|
||||
while(*h && (*h != ']') && (i < 15))
|
||||
while(*h && (*h != ']') && (i < (MAX_ZONEID_LEN - 1)))
|
||||
zoneid[i++] = *h++;
|
||||
if(!i || (']' != *h))
|
||||
return CURLUE_BAD_IPV6;
|
||||
|
|
@ -474,7 +478,7 @@ static CURLUcode hostname_check(struct Curl_URL *u, char *hostname,
|
|||
return ipv6_parse(u, hostname, hlen);
|
||||
else {
|
||||
/* letters from the second string are not ok */
|
||||
len = strcspn(hostname, " \r\n\t/:#?!@{}[]\\$\'\"^`*<>=;,+&()%|");
|
||||
len = strcspn(hostname, HOSTNAME_INVALID_CHARS);
|
||||
if(hlen != len)
|
||||
/* hostname with bad content */
|
||||
return CURLUE_BAD_HOSTNAME;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue