Bug #68129 [NEW]: parse_url() - incomplete support for empty usernames and passwords

From: Date: Thu, 02 Oct 2014 00:58:06 +0000
Subject: Bug #68129 [NEW]: parse_url() - incomplete support for empty usernames and passwords
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187788@lists.php.net to get a copy of this message
From: vort dot fu at gmail dot com Operating system: OS X 10.9.5 PHP version: 5.6.0 Package: URL related Bug Type: Bug Bug description:parse_url() - incomplete support for empty usernames and passwords Description: ------------ Section 3.1 "Common Internet Scheme Syntax" of RFC-1738 "Uniform Resource Locators (URL)" (https://www.ietf.org/rfc/rfc1738.txt) states the following: Note that an empty user name or password is different than no user name or password; there is no way to specify a password without specifying a user name. E.g., <URL:ftp://@host.com/> has an empty user name and no password, <URL:ftp://host.com/> has no user name, while <URL:ftp://foo:@host.com/> has a user name of "foo" and an empty password. parse_url() currently only supports empty user names if a password component is not specified (including empty passwords, which aren't supported at all) Test script: --------------- <?php // correct (returns empty username) var_dump( parse_url( 'https://@example.com' ) ); // incorrect (doesn't return empty username or password) var_dump( parse_url( 'https://:@example.com' ) ); // incorrect (doesn't return empty username) var_dump( parse_url( 'https://:password@example.com' ) ); // incorrect (doesn't return empty password) var_dump( parse_url( 'https://username:@example.com' ) ); Expected result: ---------------- array(3) { ["scheme"]=> string(5) "https" ["host"]=> string(11) "example.com" ["user"]=> string(0) "" } array(4) { ["scheme"]=> string(5) "https" ["host"]=> string(11) "example.com" ["user"]=> string(0) "" ["pass"]=> string(0) "" } array(4) { ["scheme"]=> string(5) "https" ["host"]=> string(11) "example.com" ["user"]=> string(0) "" ["pass"]=> string(8) "password" } array(4) { ["scheme"]=> string(5) "https" ["host"]=> string(11) "example.com" ["user"]=> string(8) "username" ["pass"]=> string(0) "" } Actual result: -------------- array(3) { ["scheme"]=> string(5) "https" ["host"]=> string(11) "example.com" ["user"]=> string(0) "" } array(2) { ["scheme"]=> string(5) "https" ["host"]=> string(11) "example.com" } array(3) { ["scheme"]=> string(5) "https" ["host"]=> string(11) "example.com" ["pass"]=> string(8) "password" } array(3) { ["scheme"]=> string(5) "https" ["host"]=> string(11) "example.com" ["user"]=> string(8) "username" } -- Edit bug report at https://bugs.php.net/bug.php?id=68129&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68129&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68129&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68129&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=68129&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=68129&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=68129&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=68129&r=needscript Try newer version: https://bugs.php.net/fix.php?id=68129&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=68129&r=support Expected behavior: https://bugs.php.net/fix.php?id=68129&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=68129&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=68129&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=68129&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68129&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=68129&r=dst IIS Stability: https://bugs.php.net/fix.php?id=68129&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=68129&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=68129&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=68129&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=68129&r=mysqlcfg

« previous php.bugs (#187788) next »