]> granicus.if.org Git - php/commitdiff
MFH: Added scheme validation for parse_url().
authorIlia Alshanetsky <iliaa@php.net>
Thu, 26 May 2005 03:56:45 +0000 (03:56 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 26 May 2005 03:56:45 +0000 (03:56 +0000)
ext/standard/url.c

index 700199e070a797356e763d0150dd64be756c7a81..b6514850e6637398c9254682e530200ec41c98b8 100644 (file)
@@ -104,6 +104,19 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
 
        /* parse scheme */
        if ((e = memchr(s, ':', length)) && (e - s)) {
+               /* validate scheme */
+               p = s;
+               while (p < e) {
+                       if (!isalnum(*p)) {
+                               if (e + 1 < ue) {
+                                       goto parse_port;
+                               } else {
+                                       goto just_path;
+                               }
+                       }
+                       p++;
+               }
+       
                if (*(e + 1) == '\0') { /* only scheme is available */
                        ret->scheme = estrndup(s, (e - s));
                        php_replace_controlchars_ex(ret->scheme, (e - s));