Bug #70942 [Opn]: parse_url for url without port and scheme, but with port-like string in url

From: Date: Fri, 20 Nov 2015 14:46:27 +0000
Subject: Bug #70942 [Opn]: parse_url for url without port and scheme, but with port-like string in url
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197354@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70942&edit=1 ID: 70942 Updated by: laruence@php.net Reported by: taco at procurios dot nl Summary: parse_url for url without port and scheme, but with port-like string in url Status: Open Type: Bug Package: URL related Operating System: linux PHP Version: 5.6.15 -Assigned To: +Assigned To: datibbaw Block user comment: N Private report: N New Comment: @datibbaw, could you have a look into this one? thanks Previous Comments: ------------------------------------------------------------------------ [2015-11-20 09:25:00] 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 (https://github.com/php/php-src/commit/d7fb52ea20aba5c9ef53dfa57af3b62717c9e9e5#diff-8c81b7e6f1bafce737814315214a5f23) 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: https://tools.ietf.org/html/rfc3986#section-3.3). 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-19 15:48:51] taco at procurios dot nl Description: ------------ When a URL without a scheme and port, but with a port-like string (e.g. example.com/foo:1234) is passed to parse_url(), a port number is returned. This wasn't the case in, at least, PHP 5.6.6 (3v4l.org seems to crash on this code...). I'm guessing this commit introduced this issue: https://github.com/php/php-src/commit/e49922d3f8060e47f810a24ce48d4e622b493699 Test script: --------------- var_dump(parse_url('//example.com/foo:1234')) Expected result: ---------------- Either bool(false) or array(2) { ["host"]=> string(11) "example.com" ["path"]=> string(9) "/foo:1234" } Actual result: -------------- array(3) { ["host"]=> string(11) "example.com" ["port"]=> int(1234) ["path"]=> string(9) "/foo:1234" } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70942&edit=1

« previous php.bugs (#197354) next »