|  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
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.
Block user comment
Status: Assign to:
Bug Type:
From: jona at mode dot com
New email:
PHP Version: OS:


 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu May 23 18:01:35 2024 UTC