Skip to content

Commit 2108d69

Browse files
andypostiluuu1994
authored andcommitted
Revert "Fix parse_url(): can not recognize port without scheme"
This reverts commit 72d8370. Closes phpGH-9569
1 parent 85d10cc commit 2108d69

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ PHP NEWS
2222
. Fixed GH-9584 (Avoid memory corruption when not unregistering custom session
2323
handler). (ilutov)
2424

25+
- Standard:
26+
. Revert "Fixed parse_url(): can not recognize port without scheme."
27+
(andypost)
28+
2529
15 Sep 2022, PHP 8.2.0RC2
2630

2731
- Core:

ext/standard/tests/url/parse_url_basic_011.phpt

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,42 @@ echo 'parse 127.0.0.1:9999?', PHP_EOL;
77
var_dump(parse_url('127.0.0.1:9999?'));
88
echo 'parse 127.0.0.1:9999#', PHP_EOL;
99
var_dump(parse_url('127.0.0.1:9999#'));
10+
echo 'parse internal:#feeding', PHP_EOL;
11+
var_dump(parse_url('internal:#feeding'));
12+
echo 'parse magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C', PHP_EOL;
13+
var_dump(parse_url('magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C'));
1014
?>
1115
--EXPECT--
1216
*** Testing parse_url() :can not recognize port without scheme ***
1317
parse 127.0.0.1:9999?
1418
array(3) {
15-
["host"]=>
19+
["scheme"]=>
1620
string(9) "127.0.0.1"
17-
["port"]=>
18-
int(9999)
21+
["path"]=>
22+
string(4) "9999"
1923
["query"]=>
2024
string(0) ""
2125
}
2226
parse 127.0.0.1:9999#
2327
array(3) {
24-
["host"]=>
28+
["scheme"]=>
2529
string(9) "127.0.0.1"
26-
["port"]=>
27-
int(9999)
30+
["path"]=>
31+
string(4) "9999"
2832
["fragment"]=>
2933
string(0) ""
3034
}
35+
parse internal:#feeding
36+
array(2) {
37+
["scheme"]=>
38+
string(8) "internal"
39+
["fragment"]=>
40+
string(7) "feeding"
41+
}
42+
parse magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C
43+
array(2) {
44+
["scheme"]=>
45+
string(6) "magnet"
46+
["query"]=>
47+
string(44) "xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C"
48+
}

ext/standard/url.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, bool *has_port
150150
p++;
151151
}
152152

153-
if ((p == ue || *p == '/' || *p == '?' || *p == '#') && (p - e) < 7) {
153+
if ((p == ue || *p == '/') && (p - e) < 7) {
154154
goto parse_port;
155155
}
156156

@@ -190,7 +190,7 @@ PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, bool *has_port
190190
pp++;
191191
}
192192

193-
if (pp - p > 0 && pp - p < 6 && (pp == ue || *pp == '/' || *pp == '?' || *pp == '#')) {
193+
if (pp - p > 0 && pp - p < 6 && (pp == ue || *pp == '/')) {
194194
zend_long port;
195195
char *end;
196196
memcpy(port_buf, p, (pp - p));

0 commit comments

Comments
 (0)