]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.3' into PHP-7.4
authorStanislav Malyshev <stas@php.net>
Sat, 2 Jan 2021 05:07:15 +0000 (21:07 -0800)
committerStanislav Malyshev <stas@php.net>
Sat, 2 Jan 2021 05:29:08 +0000 (21:29 -0800)
* PHP-7.3:
  Fix #77423: parse_url() will deliver a wrong host to user

1  2 
ext/standard/tests/url/parse_url_basic_001.phpt
ext/standard/tests/url/parse_url_basic_003.phpt
ext/standard/tests/url/parse_url_basic_005.phpt
ext/standard/tests/url/parse_url_unterminated.phpt
ext/standard/url.c

index 4c6190f3bc2f004f941b2ab1e5f2c1e5d014ed80,157d61466e698bf3a9e679ac3385a88d56eff1fa..eab770fb26449542912c930bcc581ab18b0aaaaf
@@@ -98,6 -102,24 +98,24 @@@ static const char *binary_strcspn(cons
        return e;
  }
  
 -      char *valid = "-._~!$&'()*+,;=:";
 -      char *p = str;
+ static int is_userinfo_valid(const char *str, size_t len)
+ {
++      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;