]> granicus.if.org Git - php/commitdiff
Scan for : in host:port pair from right instead of left.
authorSara Golemon <pollita@php.net>
Mon, 15 Dec 2003 06:54:31 +0000 (06:54 +0000)
committerSara Golemon <pollita@php.net>
Mon, 15 Dec 2003 06:54:31 +0000 (06:54 +0000)
This will allow handling of http://[fe80::1]:443/foo.html
IPv6 Numeric addressing with port number to parse correctly.

ext/standard/url.c

index 1996bb574c468158794aa72b071ae2f9e350dc9a..3c30e2407dc2bc4cbb744ed6a4b2cec210c5728a 100644 (file)
@@ -200,7 +200,11 @@ PHPAPI php_url *php_url_parse(char *str)
        }
        
        /* check for port */
-       if ((p = memchr(s, ':', (e-s)))) {
+       /* memrchr is a GNU specific extension
+          Emulate for wide compatability */
+       for(p = e; *p != ':' && p >= s; p--);
+
+       if (*p == ':') {
                if (!ret->port) {
                        p++;
                        if (e-p > 5) { /* port cannot be longer then 5 characters */
@@ -228,7 +232,7 @@ PHPAPI php_url *php_url_parse(char *str)
                efree(ret);
                return NULL;
        }
-       
+
        ret->host = estrndup(s, (p-s));
        php_replace_controlchars(ret->host);