diff options
Diffstat (limited to 'ext/standard/url.c')
-rw-r--r-- | ext/standard/url.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/ext/standard/url.c b/ext/standard/url.c index fb6bc9f6d..48848d7ce 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -15,7 +15,7 @@ | Author: Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: url.c,v 1.81.2.2 2005/01/27 16:38:05 iliaa Exp $ */ +/* $Id: url.c,v 1.81.2.5 2005/08/16 14:15:43 iliaa Exp $ */ #include <stdlib.h> #include <string.h> @@ -104,6 +104,26 @@ 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) { + /* scheme = 1*[ lowalpha | digit | "+" | "-" | "." ] */ + if (!isalpha(*p) && !isdigit(*p) && *p != '+' && *p != '.' && *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)); + goto end; + } + /* * certain schemas like mailto: and zlib: may not have any / after them * this check ensures we support those. @@ -303,7 +323,7 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length) ret->path = estrndup(s, (ue-s)); php_replace_controlchars_ex(ret->path, (ue - s)); } - +end: return ret; } /* }}} */ |