Revision: 14867
Author:   adrian.chadd
Date:     Sat Jul  9 01:52:03 2011
Log:      * Add []: to the list of valid URL characters (ipv6 addresses)
* modify the port parsing function to not get tripped up on an IPv6 address
  which has a '::' in it.

Next, figuring out how to actually parse the IPv6 address.


http://code.google.com/p/lusca-cache/source/detail?r=14867

Modified:
 /playpen/LUSCA_HEAD_ipv6/src/url.c

=======================================
--- /playpen/LUSCA_HEAD_ipv6/src/url.c  Sun Jul  4 06:56:53 2010
+++ /playpen/LUSCA_HEAD_ipv6/src/url.c  Sat Jul  9 01:52:03 2011
@@ -43,11 +43,11 @@
 static const char valid_hostname_chars_u[] =
 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 "abcdefghijklmnopqrstuvwxyz"
-"0123456789-._";
+"0123456789-._:[]";
 static const char valid_hostname_chars[] =
 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 "abcdefghijklmnopqrstuvwxyz"
-"0123456789-.";
+"0123456789-.:[]";

 void
 urlInitialize(void)
@@ -173,11 +173,14 @@
            *t = 0;
            strcpy((char *) host, t + 1);
        }
-       /* Is there any host information? (we should eventually parse it above) 
*/
+       /* Is there any port information? (we should eventually parse it above) 
*/
+       /* If it's an IPv6 address, we need to ensure that it's not a "::" */
        if ((t = strrchr(host, ':'))) {
-           *t++ = '\0';
-           if (*t != '\0')
-               port = atoi(t);
+           if ((t - host > 1) && *(t-1) != ':') {
+               *t++ = '\0';
+               if (*t != '\0')
+                   port = atoi(t);
+           }
        }
     }
     for (t = host; *t; t++)
@@ -193,7 +196,9 @@
            *q = '\0';
        }
     }
- if (Config.onoff.check_hostnames && strspn(host, Config.onoff.allow_underscore ? valid_hostname_chars_u : valid_hostname_chars) != strlen(host)) {
+    if (Config.onoff.check_hostnames &&
+      strspn(host, Config.onoff.allow_underscore ?
+       valid_hostname_chars_u : valid_hostname_chars) != strlen(host)) {
        debug(23, 1) ("urlParse: Illegal character in hostname '%s'\n", host);
        return NULL;
     }

--
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en.

Reply via email to