php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64604 parse_url is inconsistent with specified port
Submitted: 2013-04-07 13:14 UTC Modified: 2014-04-25 00:52 UTC
From: franssen dot roland at gmail dot com Assigned: yohgaki (profile)
Status: Closed Package: URL related
PHP Version: 5.4.13 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: franssen dot roland at gmail dot com
New email:
PHP Version: OS:

 

 [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"
}

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-04-07 13:16 UTC] franssen dot roland at gmail dot com
typo.
 [2013-04-07 13:16 UTC] franssen dot roland at gmail dot com
-Summary: parse_url without is inconsistent with specified port +Summary: parse_url is inconsistent with specified port
 [2013-07-26 10:59 UTC] info at solidsystem dot it
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
)
 [2013-11-19 22:52 UTC] yohgaki@php.net
It seems OK to merge 5.4.
Any comments?
 [2013-11-23 10:06 UTC] yohgaki@php.net
-Assigned To: +Assigned To: yohgaki
 [2014-04-14 01:42 UTC] stas@php.net
Automatic comment on behalf of ingo.walz@googlemail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b05c088a3abf8e4c6fb6e40418423a9e2dd3d929
Log: Fixed bug #64604
 [2014-04-14 01:42 UTC] stas@php.net
-Status: Assigned +Status: Closed
 [2014-04-15 12:04 UTC] ab@php.net
Automatic comment on behalf of ingo.walz@googlemail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b05c088a3abf8e4c6fb6e40418423a9e2dd3d929
Log: Fixed bug #64604
 [2014-04-15 13:05 UTC] ab@php.net
Automatic comment on behalf of ingo.walz@googlemail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b05c088a3abf8e4c6fb6e40418423a9e2dd3d929
Log: Fixed bug #64604
 [2014-04-25 00:40 UTC] stas@php.net
-Status: Closed +Status: Re-Opened
 [2014-04-25 00:40 UTC] stas@php.net
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.
 [2014-04-25 00:52 UTC] stas@php.net
See http://3v4l.org/I7GUt for BC break example.
 [2014-04-25 06:39 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8ae92cd4a5e88e6290ea2852128774eca76d71dc
Log: Revert &quot;Fixed bug #64604&quot;
 [2014-04-25 06:39 UTC] stas@php.net
-Status: Re-Opened +Status: Closed
 [2014-04-25 07:08 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a32880380335a8bc25140ddb0e94b49c47416bbe
Log: Revert &quot;Fixed bug #64604&quot;
 [2014-04-25 23:25 UTC] ab@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a32880380335a8bc25140ddb0e94b49c47416bbe
Log: Revert &quot;Fixed bug #64604&quot;
 [2014-04-25 23:29 UTC] ab@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a32880380335a8bc25140ddb0e94b49c47416bbe
Log: Revert &quot;Fixed bug #64604&quot;
 [2014-04-30 08:40 UTC] jpauli@php.net
Automatic comment on behalf of jpauli
Revision: http://git.php.net/?p=php-src.git;a=commit;h=da80c3b62fb6fe4835fb3d31953ceae918006af2
Log: Revert &quot;Fixed bug #64604&quot;
 [2014-05-01 14:59 UTC] tyrael@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a32880380335a8bc25140ddb0e94b49c47416bbe
Log: Revert &quot;Fixed bug #64604&quot;
 [2014-05-01 14:59 UTC] tyrael@php.net
Automatic comment on behalf of ingo.walz@googlemail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b05c088a3abf8e4c6fb6e40418423a9e2dd3d929
Log: Fixed bug #64604
 [2014-10-07 23:15 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=a32880380335a8bc25140ddb0e94b49c47416bbe
Log: Revert &quot;Fixed bug #64604&quot;
 [2014-10-07 23:15 UTC] stas@php.net
Automatic comment on behalf of ingo.walz@googlemail.com
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=b05c088a3abf8e4c6fb6e40418423a9e2dd3d929
Log: Fixed bug #64604
 [2014-10-07 23:26 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=a32880380335a8bc25140ddb0e94b49c47416bbe
Log: Revert &quot;Fixed bug #64604&quot;
 [2014-10-07 23:26 UTC] stas@php.net
Automatic comment on behalf of ingo.walz@googlemail.com
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=b05c088a3abf8e4c6fb6e40418423a9e2dd3d929
Log: Fixed bug #64604
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Jan 20 09:03:33 2022 UTC