|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73639 parse_url fails when ? is present in the password section
Submitted: 2016-12-02 01:47 UTC Modified: 2016-12-03 00:04 UTC
From: jazzerman+php at gmail dot com Assigned:
Status: Duplicate Package: *URL Functions
PHP Version: 5.6.28 OS: Linux
Private report: No CVE-ID: None
 [2016-12-02 01:47 UTC] jazzerman+php at gmail dot com
From manual page:

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';


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';


Expected result:
    [scheme] => mysql
    [host] => localhost
    [user] => username
    [pass] => zZ?Zmasdfj3459f8g7L0I$Ai5}OGe
    [path] => /db_name
    [query] => charset=utf8

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-02 01:54 UTC]
-Status: Open +Status: Duplicate
 [2016-12-02 01:54 UTC]
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 18:01 UTC] jazzerman+php at gmail dot com
-Status: Duplicate +Status: Closed
 [2016-12-02 18:01 UTC] 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-03 00:04 UTC]
-Status: Closed +Status: Duplicate
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 22:01:31 2024 UTC