Bug #80266 [NEW]: parse_url silently drops invalid port number, inconsistent across platforms
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)
- smiley at chillerlan dot net
- sjon@php.netBug #80266 [Opn->Nab]: parse_url silently drops invalid port number, inconsistent across platforms
- requinix@php.netBug #80266 [Nab->Opn]: parse_url silently drops invalid port number, inconsistent across platforms
- smiley at chillerlan dot netBug #80266 [Opn]: parse_url silently drops invalid port number, inconsistent across platforms
- cmb@php.netBug #80266 [Opn]: parse_url silently drops invalid port number, inconsistent across platforms
- smiley at chillerlan dot netBug #80266 [Opn]: parse_url silently drops invalid port number, inconsistent across platforms
- cmb@php.netBug #80266 [PATCH]: parse_url silently drops port number 0
- cmb@php.netBug #80266 [Asn->Csd]: parse_url silently drops port number 0