|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-07-27 02:33 UTC] xmlguy at hotmail dot com
Description:
------------
If key contains more than one set of square brackets, the key value pair is not decoded properly. For example, a form with a series of input elements named such as "formname[0].fieldname[0]" will cause incorrect and missing key/value pairs to be stored into the $_POST array.
In researching the existing bug list, I noticed that there have been numerous variations of bugs reported when form data contains url encoded data, such as occurs when the brackets are encoded as %5b and %5d. However these bugs have apparently been closed without actually fixing this problem. Perhaps a more thorough analysis of this problem is warranted to keep it from lingering on for a few more years before this report is closed. The Adobe acrobat products/reader have just started to encode form names in this format, so it could become a very serious issue if PHP cannot correctly process this form data.
Reproduce code:
---------------
<html>
<head><title>Form Submit Test Script</title></head>
<body>
<form name='fm1' action="<? echo ($_SERVER["HTTP_REFERER"])?>" method='post'>
<input type='text' name='form1[0].firstname[0]' value='John' />
<input type='text' name='form1[0].lastname[0]' value='Doe' />
<input type='submit' />
</form>
<?
var_dump($_POST);
?>
</body>
</html>
Expected result:
----------------
array(2) { ["form1[0].firstname[0]"]=> string(5) "billy" ["form1[0].lastname[0]"]=> string(4) "joel" }
Actual result:
--------------
array(1) { ["form1"]=> array(1) { [0]=> string(4) "joel" } }
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 18:00:01 2025 UTC |
fwiw, python parses this properly. I'm just seeing an empty array! <form enctype="multipart/form-data" action='/fileupload.php' method=post> <input multiple=true type=file name='file["my{}stuff"].data'><input type=submit value='submit'></form> var_dump($_FILES) yields: array(0) {} If I change the 'action' to a python script, I see this: [ { 'file["my{}stuff"].data’, ‘testfile2.txt’, ‘this is another test file (2)\n’ }, { ‘file["my{}stuff"].data’, ‘testfile1.txt’, ‘this is test file 1\n’ } ] ] POST source: Content-Type: multipart/form-data; boundary=---------------------------141539390286251557952150290 Content-Length: 468 -----------------------------141539390286251557952150290 Content-Disposition: form-data; name="file[\"my{}stuff\"].data"; filename="testfile2.txt" Content-Type: text/plain this is another test file (2) -----------------------------141539390286251557952150290 Content-Disposition: form-data; name="file[\"my{}stuff\"].data"; filename="testfile1.txt" Content-Type: text/plain this is test file 1 -----------------------------141539390286251557952150290--