mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 16:18:48 -05:00
Curl_http: strip off [brackets] from ipv6-only host headers
Since the host name is passed in to the cookie engine it will not work correctly if the brackets are left in the name. Bug:http://curl.haxx.se/mail/lib-2012-03/0036.html
This commit is contained in:
parent
b50e9e9e9e
commit
e650dbde86
16
lib/http.c
16
lib/http.c
@ -1840,9 +1840,19 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
/* ignore empty data */
|
/* ignore empty data */
|
||||||
free(cookiehost);
|
free(cookiehost);
|
||||||
else {
|
else {
|
||||||
char *colon = strchr(cookiehost, ':');
|
/* If the host begins with '[', we start searching for the port after
|
||||||
if(colon)
|
the bracket has been closed */
|
||||||
*colon = 0; /* The host must not include an embedded port number */
|
int startsearch = 0;
|
||||||
|
if(*cookiehost == '[') {
|
||||||
|
char *closingbracket = strchr(++cookiehost, ']');
|
||||||
|
if(closingbracket)
|
||||||
|
*closingbracket = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
char *colon = strchr(cookiehost + startsearch, ':');
|
||||||
|
if(colon)
|
||||||
|
*colon = 0; /* The host must not include an embedded port number */
|
||||||
|
}
|
||||||
Curl_safefree(conn->allocptr.cookiehost);
|
Curl_safefree(conn->allocptr.cookiehost);
|
||||||
conn->allocptr.cookiehost = cookiehost;
|
conn->allocptr.cookiehost = cookiehost;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user