php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71646 parse_url fails to parse relative url with port-like string in url
Submitted: 2016-02-22 18:28 UTC Modified: 2021-04-21 12:21 UTC
Votes:19
Avg. Score:4.2 ± 1.1
Reproduced:19 of 19 (100.0%)
Same Version:2 (10.5%)
Same OS:12 (63.2%)
From: jona at mode dot com Assigned: cmb (profile)
Status: Not a bug Package: URL related
PHP Version: 5.6.18 OS: linux
Private report: No CVE-ID: None
 [2016-02-22 18:28 UTC] jona at mode dot com
Description:
------------
When a relative URL without a scheme and port, but with a port-like string (e.g. /example.com/foo:1234) is passed to parse_url(), it fails to parse the URL (returning false).

Test script:
---------------
var_dump(parse_url("/foo/bar:1"));

Expected result:
----------------
array(1) {
  ["path"]=>
  string(10) "/foo/bar:1"
}

Actual result:
--------------
false

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-23 12:04 UTC] cmb@php.net
This appears to be a duplicate of bug #70942.
 [2016-02-23 14:55 UTC] jona at mode dot com
This bug is for a relative URL. Bug 70942 is a schema-less absolute URL.
 [2021-04-21 12:21 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-04-21 12:21 UTC] cmb@php.net
> This bug is for a relative URL. Bug 70942 is a schema-less
> absolute URL.

Right, but both issues have the same root cause, namely that the
colon is recognized as port delimiter, and as such the URL is
recognized as invalid.  It is already documented[1] that

| Partial URLs are also accepted, parse_url() tries its best to
| parse them correctly.

So this is not a bug.  If you feel that parse_url() should be
improved wrt. partial URLs, please pursue the RFC process[2].

[1] <https://www.php.net/parse_url>
[2] <https://wiki.php.net/rfc/howto>
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue May 11 23:01:25 2021 UTC