|  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: -
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
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-04-23 18:26 UTC] alex dot a dot pott at gmail dot com
If you manually extract the query string from\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

Test script:
$url = "\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);
// Ouptput: array(2) {
//  ["foo"]=>
//  string(4) "bar3"
//  ["_foo"]=>
//  string(4) "bar2"

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

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-04-28 16:47 UTC]
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-2021 The PHP Group
All rights reserved.
Last updated: Sun Jun 13 21:01:24 2021 UTC