|  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
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
When a relative URL without a scheme and port, but with a port-like string (e.g. / is passed to parse_url(), it fails to parse the URL (returning false).

Test script:

Expected result:
array(1) {
  string(10) "/foo/bar:1"

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-23 12:04 UTC]
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]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-04-21 12:21 UTC]
> 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] <>
[2] <>
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Dec 04 20:01:27 2023 UTC