Skip to content

Commit b57e6a4

Browse files
author
Ilia Alshanetsky
committed
MFH: Added scheme validation for parse_url().
1 parent 0943b79 commit b57e6a4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ext/standard/url.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,19 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
104104

105105
/* parse scheme */
106106
if ((e = memchr(s, ':', length)) && (e - s)) {
107+
/* validate scheme */
108+
p = s;
109+
while (p < e) {
110+
if (!isalnum(*p)) {
111+
if (e + 1 < ue) {
112+
goto parse_port;
113+
} else {
114+
goto just_path;
115+
}
116+
}
117+
p++;
118+
}
119+
107120
if (*(e + 1) == '\0') { /* only scheme is available */
108121
ret->scheme = estrndup(s, (e - s));
109122
php_replace_controlchars_ex(ret->scheme, (e - s));

0 commit comments

Comments
 (0)