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

diff --git a/NEWS b/NEWS
index 10e45f12a5fbfb92c7b0a47c236c197d8a484a8a..9cc73c9f0739869a83a078cef80f0fd6515a42dd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ PHP 4                                                                      NEWS
   then 1 character long. (Ilia)
 - Fixed handling of return values from storred procedures in mssql_execute()
   with multiple result sets returned. (Frank)
+- Fixed bug #28187 (parse_url() not handling embedded IPv6 in URLs). (Sara)
 - Fixed bug #28147 (Crash with drawing anti-aliased lines). (Derick)
 - Fixed bug #28112 (sqlite_query() crashing apache on malformed query). (Ilia,
   Marcus)
index 05e549c422642a96b5f7a2b4229cc1a0e8c0d4b1..06d5b2a6787f7343bb5286a8517f45b1377cbd3d 100644 (file)
@@ -194,7 +194,18 @@ PHPAPI php_url *php_url_parse(char *str)
        }
        
        /* check for port */
-       if ((p = memchr(s, ':', (e-s)))) {
+       if (*s == '[' && *(e-1) == ']') {
+               /* Short circuit portscan
+                  we're dealing with an
+                  IPv6 embedded address */
+               p = s;
+       } else {
+               /* memchr is a GNU specific extension
+                  Emulate for wide compatability */
+               for(p = e; *p != ':' && p >= s; p--);
+       }
+
+       if (p >= s && *p == ':') {
                if (!ret->port) {
                        p++;
                        if (e-p > 5) { /* port cannot be longer then 5 characters */
@@ -213,6 +224,11 @@ PHPAPI php_url *php_url_parse(char *str)
        } else {
                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) {