]> granicus.if.org Git - php/commitdiff
BugFix 28187 parse_url does not handle scheme://[0123:4567::89]:12345/etc style IPv6...
authorSara Golemon <pollita@php.net>
Tue, 27 Apr 2004 19:13:13 +0000 (19:13 +0000)
committerSara Golemon <pollita@php.net>
Tue, 27 Apr 2004 19:13:13 +0000 (19:13 +0000)
ext/standard/url.c

index 76bbc5c43d34acdba284b2162c7c4c1f9b50d733..69dd45d7d9161529353f71150d2d2b84bb0ba1f4 100644 (file)
@@ -198,13 +198,20 @@ PHPAPI php_url *php_url_parse(char const *str)
                
                s = p + 1;
        }
-       
+
        /* check for port */
-       /* memrchr is a GNU specific extension
-          Emulate for wide compatability */
-       for(p = e; *p != ':' && p >= s; p--);
+       if (*s == '[' && *(e-1) == ']') {
+               /* Short circuit portscan, 
+                  we're dealing with an 
+                  IPv6 embedded address */
+               p = s;
+       } else {
+               /* memrchr is a GNU specific extension
+                  Emulate for wide compatability */
+               for(p = e; *p != ':' && p >= s; p--);
+       }
 
-       if (*p == ':') {
+       if (p >= s && *p == ':') {
                if (!ret->port) {
                        p++;
                        if (e-p > 5) { /* port cannot be longer then 5 characters */
@@ -224,6 +231,11 @@ PHPAPI php_url *php_url_parse(char const *str)
                p = e;
        }
        
+       if (*s == '[' && *(p-1) == ']') {
+               s++;
+               p--;
+       }
+
        /* check if we have a valid host, if we don't reject the string as url */
        if ((p-s) < 1) {
                STR_FREE(ret->scheme);