php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #25139 parse_str should optionally not mangle array index names
Submitted: 2003-08-18 22:35 UTC Modified: 2003-08-19 03:13 UTC
From: sibaz at sibaz dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.3.2 OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: sibaz at sibaz dot com
New email:
PHP Version: OS:

 

 [2003-08-18 22:35 UTC] sibaz at sibaz dot com
Description:
------------
Understandably parse_str mangles CGI field names to fit into the PHP variable name space.  
When given a second array parameter the mangled variable names are used as indexes in the array, as documented. However the more intuitive implementation would be for the array index to be the actual unmangled CGI field name specified.  It makes more sense to me, to not mangle variable names, when populating an array.  
Clearly a change of existing behaviour would be damaging, so perhaps a config or ini setting could be used to turn off name mangling for array indexes, or perhaps a third optional parameter to the function could dictate whether or not to mangle the names.  
The primary need for this is to avoid mangling when using fieldnames that are sqlfield names.  These may contain dots if the field name is fully qualified to include the table name it is dotted.  It seems a waste to have to invent a separate mangling process for phpfield name (hiding sqlfield name) just because of unneeded, unpreventable mangling within php.  IMHO $_GET should be an array of unmangled CGI Field names.  

Reproduce code:
---------------
$array=array();
parse_str("this.that=1", $array);
echo serialize($array)."<br>\n";
// prints a:1:{s:9:"this_that";s:1:"1";}


Expected result:
----------------
// ideally it should print a:1:{s:9:"this.that";s:1:"1";}

Actual result:
--------------
// it currently prints a:1:{s:9:"this_that";s:1:"1";}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-18 22:39 UTC] sibaz at sibaz dot com
Summary was unclearly worded
 [2003-08-19 03:13 UTC] derick@php.net
We can not change it as you suggested, and we are not going to add an ini-setting for this because that will make writing portable scripts much harder.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 19:01:30 2024 UTC