<div dir="ltr"><div>Hi,<br><br></div>Here's a simple patch to allow literal IPv6 addresses in URLs.<br><br>--- a/src/core/uri.c<br>+++ b/src/core/uri.c<br>@@ -205,7 +205,13 @@ struct uri * parse_uri ( const char *uri_string ) {<br>
        }<br> <br>        /* Split host into host[:port] */<br>-       if ( ( tmp = strchr ( uri->host, ':' ) ) ) {<br>+       if ( *(uri->host) == '[' && ( tmp = strchr( uri->host, ']' ) ) ) {<br>
+               uri->host++;<br>+               *(tmp++) = '\0';<br>+               if ( *tmp == ':' ) {<br>+                       uri->port = tmp++;<br>+               }<br>+       } else if ( ( tmp = strchr ( uri->host, ':' ) ) ) {<br>
                *(tmp++) = '\0';<br>                uri->port = tmp;<br>        }<br>@@ -296,6 +302,12 @@ int unparse_uri ( char *buf, size_t size, struct uri *uri,<br>                                used += ssnprintf ( buf + used, size - used,<br>
                                                    "%c", sep );<br> <br>+                       /* Prefix IPv6 addresses with [ */<br>+                       if ( i == 4 && strchr( field, ':' ) ) {<br>
+                               used += ssnprintf ( buf + used, size - used,<br>+                                                   "[" );<br>+                       }<br>+<br>                        /* Print contents of field, possibly encoded */<br>
                        if ( URI_ENCODED & ( 1 << i ) )<br>                                used += uri_encode ( field, buf + used,<br>@@ -303,6 +315,12 @@ int unparse_uri ( char *buf, size_t size, struct uri *uri,<br>
                        else<br>                                used += ssnprintf ( buf + used, size - used,<br>                                                    "%s", field );<br>+<br>+                       /* Postfix IPv6 addresses with ] */<br>
+                       if ( i == 4 && strchr( field, ':' ) ) {<br>+                               used += ssnprintf ( buf + used, size - used,<br>+                                                   "]" );<br>
+                       }<br>                }<br>        }<br><br clear="all"><div><div><br>-- <br>James F. Carter <a href="http://www.jfc.org.uk" target="_blank">www.jfc.org.uk</a> <a href="http://podquiz.com" target="_blank">podquiz.com</a> <a href="http://starringthecomputer.com" target="_blank">starringthecomputer.com</a><br>

</div></div></div>