Bug #80266 [NEW]: parse_url silently drops invalid port number, inconsistent across platforms

From: Date: Wed, 21 Oct 2020 06:38:00 +0000
Subject: Bug #80266 [NEW]: parse_url silently drops invalid port number, inconsistent across platforms
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229825@lists.php.net to get a copy of this message
From:             smiley at chillerlan dot net
Operating system: Linux
PHP version:      8.0.0RC2
Package:          *URL Functions
Bug Type:         Bug
Bug description:parse_url silently drops invalid port number, inconsistent across platforms

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 bug report at https://bugs.php.net/bug.php?id=80266&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=80266&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=80266&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=80266&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=80266&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=80266&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=80266&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=80266&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=80266&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=80266&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=80266&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80266&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=80266&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=80266&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=80266&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=80266&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=80266&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=80266&r=mysqlcfg


Thread (8 messages)

« previous php.bugs (#229825) next »