mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
Fix parse_url(): can not recognize port without scheme
Closes GH-7844.
This commit is contained in:
parent
adc8155119
commit
72d83709d9
1
NEWS
1
NEWS
@ -62,6 +62,7 @@ PHP NEWS
|
||||
. Fixed bug GH-7847 (stripos with large haystack has bad performance).
|
||||
(ilutov)
|
||||
. New function memory_reset_peak_usage(). (Patrick Allaert)
|
||||
. Fixed parse_url(): can not recognize port without scheme. (pandaLIU)
|
||||
|
||||
- Zip:
|
||||
. add ZipArchive::clearError() method
|
||||
|
30
ext/standard/tests/url/parse_url_basic_011.phpt
Normal file
30
ext/standard/tests/url/parse_url_basic_011.phpt
Normal file
@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
Test parse_url() function: can not recognize port without scheme
|
||||
--FILE--
|
||||
<?php
|
||||
echo "*** Testing parse_url() :can not recognize port without scheme ***\n";
|
||||
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#'));
|
||||
?>
|
||||
--EXPECT--
|
||||
*** Testing parse_url() :can not recognize port without scheme ***
|
||||
parse 127.0.0.1:9999?
|
||||
array(3) {
|
||||
["host"]=>
|
||||
string(9) "127.0.0.1"
|
||||
["port"]=>
|
||||
int(9999)
|
||||
["query"]=>
|
||||
string(0) ""
|
||||
}
|
||||
parse 127.0.0.1:9999#
|
||||
array(3) {
|
||||
["host"]=>
|
||||
string(9) "127.0.0.1"
|
||||
["port"]=>
|
||||
int(9999)
|
||||
["fragment"]=>
|
||||
string(0) ""
|
||||
}
|
@ -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 - e) < 7) {
|
||||
if ((p == ue || *p == '/' || *p == '?' || *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 == '/')) {
|
||||
if (pp - p > 0 && pp - p < 6 && (pp == ue || *pp == '/' || *pp == '?' || *pp == '#')) {
|
||||
zend_long port;
|
||||
char *end;
|
||||
memcpy(port_buf, p, (pp - p));
|
||||
|
Loading…
Reference in New Issue
Block a user