|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70942 parse_url for url without port and scheme, but with port-like string in url
Submitted: 2015-11-19 15:48 UTC Modified: 2017-10-24 07:15 UTC
Avg. Score:4.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: taco at procurios dot nl Assigned:
Status: Open Package: URL related
PHP Version: 5.6.15 OS: linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-11-19 15:48 UTC] taco at procurios dot nl
When a URL without a scheme and port, but with a port-like string (e.g. is passed to parse_url(), a port number is returned. This wasn't the case in, at least, PHP 5.6.6 ( seems to crash on this code...).

I'm guessing this commit introduced this issue:

Test script:

Expected result:



array(2) {
  string(11) ""
  string(9) "/foo:1234"

Actual result:
array(3) {
  string(11) ""
  string(9) "/foo:1234"


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-11-20 09:25 UTC] taco at procurios dot nl
The commit I've mentioned does not introduce this issue. Afaik, this issue is much older, but was 'masked' by bug #68917. After this bug was fixed ( parse_url no longer returned false for URLs without a scheme, but with a colon.

parse_url assumes that the colon character can only be used for the port subcomponent of a URI, but it is allowed in the path component too (see: The parser should look for a colon character, but not after the first single slash in a URL, anything after that slash is part of the path, query or fragment.
 [2015-11-20 14:46 UTC]
-Assigned To: +Assigned To: datibbaw
 [2015-11-20 14:46 UTC]
@datibbaw, could you have a look into this one? thanks
 [2016-08-17 09:50 UTC] driezasson at icloud dot com
Even a URL with a port, but without a scheme doesn’t get parsed. E.g.: '//'.

Expected result:
['host' => '', 'port' => 80]

Actual result:
 [2017-10-24 07:15 UTC]
-Status: Assigned +Status: Open -Assigned To: datibbaw +Assigned To:
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC