Bug #72811 [Com]: parse_url fails with IPv6 host

From: Date: Sat, 13 Aug 2016 19:34:58 +0000
Subject: Bug #72811 [Com]: parse_url fails with IPv6 host
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203244@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72811&edit=1 ID: 72811 Comment by: vhu at iki dot fi Reported by: me at kelunik dot com Summary: parse_url fails with IPv6 host Status: Open Type: Bug Package: URL related Operating System: * PHP Version: Irrelevant Block user comment: N Private report: N New Comment: 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 ;) Previous Comments: ------------------------------------------------------------------------ [2016-08-11 11:47:37] me at kelunik dot com Description: ------------ PHP fails to parse the host part if an IPv6 address is used in combination with a port. Test script: --------------- <?php // See https://3v4l.org/7uVWs var_dump(parse_url("127.0.0.1:80", PHP_URL_HOST)); var_dump(parse_url("[::1]:80", PHP_URL_HOST)); Expected result: ---------------- string(9) "127.0.0.1" string(5) "[::1]" Actual result: -------------- string(9) "127.0.0.1" NULL ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72811&edit=1

« previous php.bugs (#203244) next »