Index: nanohttp.c
===================================================================
--- nanohttp.c~
+++ nanohttp.c
@@ -276,6 +276,7 @@
 static void
 xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ctxt, const char *URL) {
     xmlURIPtr uri;
+    int len;
     /*
      * Clear any existing data from the context
      */
@@ -307,7 +308,14 @@
     }
     
     ctxt->protocol = xmlMemStrdup(uri->scheme);
-    ctxt->hostname = xmlMemStrdup(uri->server);
+    if (*uri->server == '[') {
+	len = strlen(uri->server) - 1;
+	if (len > 0) {
+	    ctxt->hostname = (char *) xmlMallocAtomic(len);
+	    snprintf(ctxt->hostname, len, "%s", uri->server + 1);
+	} /* else ctxt->hostname = NULL */
+    } else
+	ctxt->hostname = xmlMemStrdup(uri->server);
     if (uri->path != NULL)
 	ctxt->path = xmlMemStrdup(uri->path);
     else
