From: Stanislav Malyshev Date: Sat, 2 Jan 2021 05:07:15 +0000 (-0800) Subject: Merge branch 'PHP-7.3' into PHP-7.4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=434c2b1bdbed80f01f5bc6c817c9b87fef917919;p=php Merge branch 'PHP-7.3' into PHP-7.4 * PHP-7.3: Fix #77423: parse_url() will deliver a wrong host to user --- 434c2b1bdbed80f01f5bc6c817c9b87fef917919 diff --cc ext/standard/url.c index 4c6190f3bc,157d61466e..eab770fb26 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@@ -98,6 -102,24 +98,24 @@@ static const char *binary_strcspn(cons return e; } + static int is_userinfo_valid(const char *str, size_t len) + { - char *valid = "-._~!$&'()*+,;=:"; - char *p = str; ++ const char *valid = "-._~!$&'()*+,;=:"; ++ const char *p = str; + while (p - str < len) { + if (isalpha(*p) || isdigit(*p) || strchr(valid, *p)) { + p++; + } else if (*p == '%' && p - str <= len - 3 && isdigit(*(p+1)) && isxdigit(*(p+2))) { + p += 3; + } else { + return 0; + } + } + return 1; + } + + /* {{{ php_url_parse + */ PHPAPI php_url *php_url_parse_ex(char const *str, size_t length) { zend_bool has_port;