|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-04-07 13:14 UTC] franssen dot roland at gmail dot com
Description:
------------
Please see the test script. parse_url() is inconsistent with "//localhost:80/path"
Test script:
---------------
<?php
var_dump(parse_url('//localhost/path'));
var_dump(parse_url('//localhost:80/path'));
var_dump(parse_url('//localhost:/path'));
var_dump(parse_url('http://localhost:80/path'));
Expected result:
----------------
# //localhost/path
array(2) {
["host"]=>
string(9) "localhost"
["path"]=>
string(5) "/path"
}
# //localhost:80/path
array(2) {
["host"]=>
string(9) "localhost"
["port"]=>
int(80)
["path"]=>
string(5) "/path"
}
# //localhost:/path
array(2) {
["host"]=>
string(9) "localhost"
["path"]=>
string(5) "/path"
}
# http://localhost:80/path
array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(9) "localhost"
["port"]=>
int(80)
["path"]=>
string(5) "/path"
}
Actual result:
--------------
# //localhost/path
array(2) {
["host"]=>
string(9) "localhost"
["path"]=>
string(5) "/path"
}
# //localhost:80/path
bool(false)
# //localhost:/path
array(2) {
["host"]=>
string(9) "localhost"
["path"]=>
string(5) "/path"
}
# http://localhost:80/path
array(4) {
["scheme"]=>
string(4) "http"
["host"]=>
string(9) "localhost"
["port"]=>
int(80)
["path"]=>
string(5) "/path"
}
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 06:00:01 2025 UTC |
There's also this problem, verified on the following PHP versions: PHP Version 5.3.3-7+squeeze15 PHP Version 5.4.4-14+deb7u2 Bug: The port is wrongly parsed when the host is omitted. url: index.php?myVar=Size:10Array ( [host] => index.php [port] => 10 [query] => myVar=Size:10 ) url: http://myhost.com/index.php?myVar=Size:10Array ( [scheme] => http [host] => myhost.com [path] => /index.php [query] => myVar=Size:10 )Looks like this fix breaks this code: var_dump(parse_url("/v10/Users?fields=name,date_modified,id&filter=[{\"id\":\"a95665f7-68c5-a530-6950-5359ac6d3e7e\"}]")); before the change, it worked as expected, after the fix, it returns false.