]> granicus.if.org Git - php/commitdiff
Fix FILTER_VALIDATE_URL - Host names can't start with '.' or '-'
authorRasmus Lerdorf <rasmus@php.net>
Wed, 31 Mar 2010 23:56:30 +0000 (23:56 +0000)
committerRasmus Lerdorf <rasmus@php.net>
Wed, 31 Mar 2010 23:56:30 +0000 (23:56 +0000)
ext/filter/logical_filters.c

index 28fae502264fc9e848684e94867658e1ba581413..008b0780c0cd6a7e796c9e5ec22aeeace3d4d24b 100644 (file)
@@ -465,6 +465,11 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
                e = url->host + strlen(url->host);
                s = url->host;
 
+               /* First char of hostname must be alphanumeric */
+               if(!isalnum((int)*(unsigned char *)s)) { 
+                       goto bad_url;
+               }
+
                while (s < e) {
                        if (!isalnum((int)*(unsigned char *)s) && *s != '-' && *s != '.') {
                                goto bad_url;