Revert "Fix parse_url(): can not recognize port without scheme"

This reverts commit 72d83709d9.

Closes GH-9569
This commit is contained in:
Andy Postnikov 2022-09-17 22:50:21 +02:00 committed by Ilija Tovilo
parent 85d10cc93d
commit 2108d6983f
No known key found for this signature in database
GPG Key ID: A4F5D403F118200A
3 changed files with 30 additions and 8 deletions

4
NEWS
View File

@ -22,6 +22,10 @@ PHP NEWS
. Fixed GH-9584 (Avoid memory corruption when not unregistering custom session
handler). (ilutov)
- Standard:
. Revert "Fixed parse_url(): can not recognize port without scheme."
(andypost)
15 Sep 2022, PHP 8.2.0RC2
- Core:

View File

@ -7,24 +7,42 @@ echo 'parse 127.0.0.1:9999?', PHP_EOL;
var_dump(parse_url('127.0.0.1:9999?'));
echo 'parse 127.0.0.1:9999#', PHP_EOL;
var_dump(parse_url('127.0.0.1:9999#'));
echo 'parse internal:#feeding', PHP_EOL;
var_dump(parse_url('internal:#feeding'));
echo 'parse magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C', PHP_EOL;
var_dump(parse_url('magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C'));
?>
--EXPECT--
*** Testing parse_url() :can not recognize port without scheme ***
parse 127.0.0.1:9999?
array(3) {
["host"]=>
["scheme"]=>
string(9) "127.0.0.1"
["port"]=>
int(9999)
["path"]=>
string(4) "9999"
["query"]=>
string(0) ""
}
parse 127.0.0.1:9999#
array(3) {
["host"]=>
["scheme"]=>
string(9) "127.0.0.1"
["port"]=>
int(9999)
["path"]=>
string(4) "9999"
["fragment"]=>
string(0) ""
}
parse internal:#feeding
array(2) {
["scheme"]=>
string(8) "internal"
["fragment"]=>
string(7) "feeding"
}
parse magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C
array(2) {
["scheme"]=>
string(6) "magnet"
["query"]=>
string(44) "xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C"
}

View File

@ -150,7 +150,7 @@ PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, bool *has_port
p++;
}
if ((p == ue || *p == '/' || *p == '?' || *p == '#') && (p - e) < 7) {
if ((p == ue || *p == '/') && (p - e) < 7) {
goto parse_port;
}
@ -190,7 +190,7 @@ PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, bool *has_port
pp++;
}
if (pp - p > 0 && pp - p < 6 && (pp == ue || *pp == '/' || *pp == '?' || *pp == '#')) {
if (pp - p > 0 && pp - p < 6 && (pp == ue || *pp == '/')) {
zend_long port;
char *end;
memcpy(port_buf, p, (pp - p));