pollita         Tue Apr 27 15:13:14 2004 EDT

  Modified files:              
    /php-src/ext/standard       url.c 
  Log:
  BugFix 28187 parse_url does not handle scheme://[0123:4567::89]:12345/etc style IPv6 
embedded address URLs
  
http://cvs.php.net/diff.php/php-src/ext/standard/url.c?r1=1.77&r2=1.78&ty=u
Index: php-src/ext/standard/url.c
diff -u php-src/ext/standard/url.c:1.77 php-src/ext/standard/url.c:1.78
--- php-src/ext/standard/url.c:1.77     Sun Jan 25 10:08:31 2004
+++ php-src/ext/standard/url.c  Tue Apr 27 15:13:13 2004
@@ -15,7 +15,7 @@
    | Author: Jim Winstead <[EMAIL PROTECTED]>                                  |
    +----------------------------------------------------------------------+
  */
-/* $Id: url.c,v 1.77 2004/01/25 15:08:31 abies Exp $ */
+/* $Id: url.c,v 1.78 2004/04/27 19:13:13 pollita Exp $ */
 
 #include <stdlib.h>
 #include <string.h>
@@ -198,13 +198,20 @@
                
                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 @@
                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);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to