php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76255 parse_str() does not replace control characters
Submitted: 2018-04-23 18:26 UTC Modified: -
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: alex dot a dot pott at gmail dot com Assigned:
Status: Open Package: URL related
PHP Version: 7.2.4 OS: OS X & Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
40 - 25 = ?
Subscribe to this entry?

 
 [2018-04-23 18:26 UTC] alex dot a dot pott at gmail dot com
Description:
------------
If you manually extract the query string from http://example.com?foo=bar&\x00foo=bar2&foo=bar3 and then use parse_str() on the result it is different than if you use parse_url() and then parse_str(). This is loosely related to https://bugs.php.net/bug.php?id=66976.

Test script:
---------------
$url = "http://example.com?foo=bar&\x00foo=bar2&foo=bar3";
list($path, $query_string) = explode('?', $url, 2);
// Use parse_url() and then parse_str()
$parts = parse_url($url);
parse_str($parts['query'], $parsed_qs);
var_dump($parsed_qs);
// Ouptput: array(2) {
//  ["foo"]=>
//  string(4) "bar3"
//  ["_foo"]=>
//  string(4) "bar2"
//}

// Use parse_str()
parse_str($query_string, $parsed_qs);
var_dump($parsed_qs);
// Output: array(1) {
//  ["foo"]=>
//  string(3) "bar"
// }

Expected result:
----------------
I expect the second result to be the same as the first.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-04-28 16:47 UTC] duncan3dc@php.net
A null character isn't valid in a URL is it? Shouldn't it be encoded as %00 ?
 [2019-04-28 17:03 UTC] spam2 at rhsoft dot net
you souldn't pass random, unsanitized input to any function except one designed to sanitize input
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Sep 15 12:01:26 2019 UTC