From: Matthew Iselin <matt...@theiselins.net> Signed-off-by: Matthew Iselin <matt...@theiselins.net> --- src/core/uri.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/core/uri.c b/src/core/uri.c index 1a43206..1cbf1f1 100644 --- a/src/core/uri.c +++ b/src/core/uri.c @@ -167,9 +167,20 @@ struct uri * parse_uri ( const char *uri_string ) { /* Split host into host[:port] */ if ( ( tmp = strchr ( uri->host, ':' ) ) ) { - *(tmp++) = '\0'; - uri->port = tmp; + /* Make sure an IPv6 address isn't broken up. */ + if ( ( strchr ( uri->host, '[' ) == 0 ) || + ( tmp > strchr ( uri->host, ']' ) ) ) { + *(tmp++) = '\0'; + uri->port = tmp; + } } + + /* Handle IPv6 case. */ + if ( ( uri->host <= strchr ( uri->host, '[' ) ) && + ( tmp = strchr ( uri->host, ']' ) ) ) { + uri->host++; + *(tmp) = 0; + } } /* Decode fields that should be decoded */ @@ -411,6 +422,10 @@ static int is_unreserved_uri_char ( int c, int field ) { ( c == '-' ) || ( c == '_' ) || ( c == '.' ) || ( c == '~' ) ); + /* : is valid for an IPv6 host address */ + if ( field == URI_HOST ) + ok = ok || (c == ':'); + if ( field == URI_QUERY ) ok = ok || ( c == ';' ) || ( c == '&' ) || ( c == '=' ); -- 1.7.2.5 _______________________________________________ gPXE-devel mailing list gPXE-devel@etherboot.org http://etherboot.org/mailman/listinfo/gpxe-devel