Bug #73639 [Csd->Dup]: parse_url fails when ? is present in the password section
| From: | requinix@php.net | Date: | Sat, 03 Dec 2016 00:04:24 +0000 |
| Subject: | Bug #73639 [Csd->Dup]: parse_url fails when ? is present in the password section | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-205744@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73639&edit=1
ID: 73639
Updated by: requinix@php.net
Reported by: jazzerman+php at gmail dot com
Summary: parse_url fails when ? is present in the password
section
-Status: Closed
+Status: Duplicate
Type: Bug
Package: *URL Functions
Operating System: Linux
PHP Version: 5.6.28
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2016-12-02 18:01:53] jazzerman+php at gmail dot com
Got it! I just removed that ? form the password - that fixed the issue.
It works fine in my local development but on the production machine it was failing due to PHP
version being newer.
Thanks for your reply!
------------------------------------------------------------------------
[2016-12-02 01:54:00] requinix@php.net
Characters like ? are not allowed in the userinfo portion of URLs, and PHP accepting them in the
past was incorrect behavior. You need to urlencode() the password.
See also bug #73500
------------------------------------------------------------------------
[2016-12-02 01:47:31] jazzerman+php at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.parse-url
---
I was using PHPActiveRecord and the framework utilizes parse_url to store the settings for DB
connection. E.g.
$db_conn =
'mysql://db_username:zZ?Zmasdfj3459f8g7L0I$Ai5}OGe@localhost/db_name?charset=utf8';
print_r(parse_url($db_conn));
It was all working fine in all previous versions of PHP but with 5.6.28 for some reason it stopped
parsing the string above. After testing I realized "?" in the password field causes the
function to fail.
Please fix. Thanks!
Test script:
---------------
$db_conn =
'mysql://username:zZ?Zmasdfj3459f8g7L0I$Ai5}OGe@localhost/db_name?charset=utf8';
print_r(parse_url($db_conn));
Expected result:
----------------
Array
(
[scheme] => mysql
[host] => localhost
[user] => username
[pass] => zZ?Zmasdfj3459f8g7L0I$Ai5}OGe
[path] => /db_name
[query] => charset=utf8
)
Actual result:
--------------
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73639&edit=1