Bug #80266 [Opn->Nab]: parse_url silently drops invalid port number, inconsistent across platforms

From: Date: Wed, 21 Oct 2020 06:51:40 +0000
Subject: Bug #80266 [Opn->Nab]: parse_url silently drops invalid port number, inconsistent across platforms
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229826@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: sjon@php.net Reported by: smiley at chillerlan dot net Summary: parse_url silently drops invalid port number, inconsistent across platforms -Status: Open +Status: Not a bug Type: Bug Package: *URL Functions Operating System: Linux PHP Version: 8.0.0RC2 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php This is not a bug, for an extensive explanation see Bug #80114 https://bugs.php.net/bug.php?id=80114 Previous Comments: ------------------------------------------------------------------------ [2020-10-21 06:38:00] smiley at chillerlan dot net Description: ------------ In the current PHP 8 nightly Linux builds, parse_url() drops silently an invalid port number 0 and returns an array with the host part of an otherwise invalid URI. PHP 7 on Linux & Windows, as well as PHP 8 on Windows will return false instead, which is expected. https://github.com/chillerlan/php-httpinterface/runs/1284984428#step:10:21 https://travis-ci.org/github/chillerlan/php-httpinterface/jobs/737623526#L288 Test script: --------------- $parsed = parse_url('//portcannotbezero.com:0'); var_dump($parsed); https://github.com/chillerlan/php-httpinterface/commit/cefbdb1163d508f52f199abd4b958319b48012ba Source: https://github.com/chillerlan/php-httpinterface/blob/46b563fd9ab2b92c1cf4efa3c429d6872de2eab4/src/Psr7/Uri.php#L65-L69 https://github.com/chillerlan/php-httpinterface/blob/46b563fd9ab2b92c1cf4efa3c429d6872de2eab4/tests/Psr7/UriTest.php#L144-L149 (similar to guzzle/psr7) Expected result: ---------------- parse_url('//portcannotbezero.com:0') should return the same result "false" across all platforms. https://github.com/chillerlan/php-httpinterface/runs/1284984456 https://travis-ci.org/github/chillerlan/php-httpinterface/jobs/737623525#L287 Actual result: -------------- array(1) { 'host' => string(20) "portcannotbezero.com" } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80266&edit=1

« previous php.bugs (#229826) next »