[uri] Make URI parsing handle IPv6_address:port
authorMatthew Iselin <matthew@theiselins.net>
Mon, 30 May 2011 12:30:51 +0000 (22:30 +1000)
committerMarty Connor <mdc@etherboot.org>
Tue, 19 Jul 2011 01:48:05 +0000 (21:48 -0400)
For example:

    http://[fc00::1]:1234

Signed-off-by: Matthew Iselin <matthew@theiselins.net>
Signed-off-by: Marty Connor <mdc@etherboot.org>
src/core/uri.c

index 1cbf1f1..d339faa 100644 (file)
@@ -166,10 +166,9 @@ struct uri * parse_uri ( const char *uri_string ) {
                }
 
                /* Split host into host[:port] */
-               if ( ( tmp = strchr ( uri->host, ':' ) ) ) {
+               if ( ( tmp = strrchr ( uri->host, ':' ) ) ) {
                        /* Make sure an IPv6 address isn't broken up. */
-                       if ( ( strchr ( uri->host, '[' ) == 0 ) ||
-                            ( tmp > strchr ( uri->host, ']' ) ) ) {
+                       if ( ( tmp > strchr ( uri->host, ']' ) ) ) {
                                *(tmp++) = '\0';
                                uri->port = tmp;
                        }