summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Cipu <acipu@ixiacom.com>2012-03-10 16:48:59 +0100
committerDaniel Stenberg <daniel@haxx.se>2012-03-10 16:48:59 +0100
commite650dbde86d47fc9ded3a8328b8d765fce54078b (patch)
tree25e4cad8e300ca823e2f67020907f6b2552707ab
parentb50e9e9e9e39538b53cf56829f872f3034fc8060 (diff)
downloadgnurl-e650dbde86d47fc9ded3a8328b8d765fce54078b.tar.gz
gnurl-e650dbde86d47fc9ded3a8328b8d765fce54078b.tar.bz2
gnurl-e650dbde86d47fc9ded3a8328b8d765fce54078b.zip
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
-rw-r--r--lib/http.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/http.c b/lib/http.c
index 374de7d21..c7a6df015 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -1840,9 +1840,19 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
/* ignore empty data */
free(cookiehost);
else {
- char *colon = strchr(cookiehost, ':');
- if(colon)
- *colon = 0; /* The host must not include an embedded port number */
+ /* If the host begins with '[', we start searching for the port after
+ the bracket has been closed */
+ 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);
conn->allocptr.cookiehost = cookiehost;
}