|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72811 parse_url fails with IPv6 host
Submitted: 2016-08-11 11:47 UTC Modified: -
Avg. Score:3.7 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:3 (100.0%)
From: me at kelunik dot com Assigned:
Status: Open Package: URL related
PHP Version: Irrelevant OS: *
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: me at kelunik dot com
New email:
PHP Version: OS:


 [2016-08-11 11:47 UTC] me at kelunik dot com
PHP fails to parse the host part if an IPv6 address is used in combination with a port.

Test script:

// See

var_dump(parse_url("", PHP_URL_HOST));
var_dump(parse_url("[::1]:80", PHP_URL_HOST));

Expected result:
string(9) ""
string(5) "[::1]"

Actual result:
string(9) ""


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-13 19:34 UTC] vhu at iki dot fi
Key point here is the parsing without scheme; everything works already exactly as expected if scheme is specified. This got me thinking. How should this be parsed if there is no port number and should there a difference between IPv4 and IPv6?

Especially consider how does this compares to how browsers parse the URLs? e.g. <a href="[2001::1]/asdf"> vs <a href="http://[2001::1]/asdf">

I'm almost tempted to say that the way IPv4 URL is parsed is incorrect ;)
 [2016-08-16 12:01 UTC] me at kelunik dot com
Well, there's an explicit comment about parsing "" correctly. Same should be for true for IPs. See
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Oct 19 12:03:33 2021 UTC