Doc #80266 [Opn]: parse_url silently drops invalid port number, inconsistent across platforms

From: Date: Tue, 27 Oct 2020 11:12:46 +0000
Subject: Doc #80266 [Opn]: parse_url silently drops invalid port number, inconsistent across platforms
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18032@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80266&edit=1 ID: 80266 Updated by: nikic@php.net Reported by: smiley at chillerlan dot net Summary: parse_url silently drops invalid port number, inconsistent across platforms Status: Open Type: Documentation Problem Package: *URL Functions Operating System: Windows PHP Version: 7.3.24, 7.4.12 Block user comment: N Private report: N New Comment: | URIs with a 0 port are generally valid, so parse_url() should | recognize such URIs, but still report the port as missing. I do wonder whether that's the right behavior. It would make more sense to include the zero port in the output to me. Previous Comments: ------------------------------------------------------------------------ [2020-10-21 12:41:06] smiley at chillerlan dot net > Apparently, we should document that behavior. Yes, that would be greatly appreciated, also a mention in UPGRADING would be helpful. Thanks for clearing this up and thank you for your time! I think this can be closed then. Cheers! ------------------------------------------------------------------------ [2020-10-21 10:00:48] cmb@php.net Firstly, this is not particularly related to PHP 8.0, but rather affects PHP-7.3+. > […] in fact, you could reproduce what the Windows build of the > GH actions runner didn't. The GH actions runner uses PHP 7.4.11 (which does not have that bugfix) and some PHP 8.0.0-dev version (which presumably does not have the bugfix either). > Aside, if this is now expected behaviour, why is the "port" key > with a value 0 missing in the array From the commit message: | URIs with a 0 port are generally valid, so parse_url() should | recognize such URIs, but still report the port as missing. Apparently, we should document that behavior. ------------------------------------------------------------------------ [2020-10-21 07:44:18] smiley at chillerlan dot net @cmb: in fact, you could reproduce what the Windows build of the GH actions runner didn't. Aside, if this is now expected behaviour, why is the "port" key with a value 0 missing in the array - according to the previously linked bug, the port number 0 should be treated as valid? ------------------------------------------------------------------------ [2020-10-21 07:36:40] cmb@php.net $ x64\Debug\php -v PHP 8.0.0-dev (cli) (built: Oct 16 2020 18:46:05) ( NTS Visual C++ 2019 x64 DEBUG ) Copyright (c) The PHP Group Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies C:\php-sdk\phpdev\vs16\x64\php-src-8.0 $ x64\Debug\php -r "var_dump(parse_url('//portcannotbezero.com:0'));" array(1) { ["host"]=> string(20) "portcannotbezero.com" } IOW, I cannot reproduce. ------------------------------------------------------------------------ [2020-10-21 07:00:33] smiley at chillerlan dot net Since this was marked as "Not a bug", i'd like to point out the inconsistency across the several platforms, as well as the current behaviour in userland. The used test stems from current PSR-7 implementations where it is expected to be an invalid URI. See also: https://github.com/guzzle/psr7/blob/7858757f390bbe4b3d81762a97d6e6e786bb70ad/tests/UriTest.php#L137 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=80266 -- Edit this bug report at https://bugs.php.net/bug.php?id=80266&edit=1

« previous php.doc.bugs (#18032) next »