php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27578 parse_str() quotes array keys when magic quotes are turned ON
Submitted: 2004-03-12 07:10 UTC Modified: 2004-03-12 09:11 UTC
From: honza dot malik at ecn dot cz Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.4 OS: Linux
Private report: No CVE-ID: None
 [2004-03-12 07:10 UTC] honza dot malik at ecn dot cz
Description:
------------
parse_str() quotes array keys when magic quotes are turned ON

(it actually quotes also values, but it is probably (but unfortunatelly) desired behavior)

Reproduce code:
---------------
parse_str( 'a["key"]=something', $arr);
print_r($arr);


Expected result:
----------------
Array
(
    [a] => Array
        (
            ["key"] => something
        )
)

or maybe

Array
(
    [a] => Array
        (
            [key] => something
        )
)




Actual result:
--------------
Array
(
    [a] => Array
        (
            [\"key\"] => something
        )
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-12 09:11 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The string you pass to parse_str() should be 
'a[key]=something'. When you include " in they key name 
they are being treated as part of the name rather then 
quotes in the argument. You'll encounter the same behaviour 
is you pass foo.php?a["key"]=something and have 
magic_quotes_gpc enabled. 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 07:01:31 2024 UTC