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

index 63c5f60dd516be578ba44ab23451d8a44b3fd0e9..4d07d249bb0e5314af3202f8853c7f977d1aee72 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));