From b57e6a484ab29a476b4e0d19138e518483dbe2c9 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Thu, 26 May 2005 03:56:45 +0000 Subject: [PATCH] MFH: Added scheme validation for parse_url(). --- ext/standard/url.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ext/standard/url.c b/ext/standard/url.c index 700199e070..b6514850e6 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -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)); -- 2.40.0