php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #29401 Form POST not decoded properly
Submitted: 2004-07-27 02:33 UTC Modified: 2017-01-29 04:22 UTC
Votes:5
Avg. Score:4.8 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:1 (25.0%)
From: xmlguy at hotmail dot com Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 4.3.8 OS: Win XP Pro
Private report: No CVE-ID: None
 [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" } }



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-27 02:44 UTC] xmlguy at hotmail dot com
with the version of the form I posted, the expected and actual result sample data should obviously reflect the strings "John" and "Doe" instead of "billy" and "joel", respectfully.
 [2004-10-08 16:17 UTC] moriyoshi@php.net
How come this could be a mbstring related problem..?
 [2004-10-12 00:32 UTC] xmlguy at hotmail dot com
I indicated this as an mbstring related problem because the similar bugs I found used this as the category.

See bugs 20114 19507 19347 20024 20133.
 [2011-12-21 18:06 UTC] mikebianc at aol dot com
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--
 [2017-01-20 20:23 UTC] heiglandreas@php.net
-Status: Open +Status: Feedback -Package: Feature/Change Request +Package: *General Issues
 [2017-01-20 20:23 UTC] heiglandreas@php.net
Is this still relevant?
 [2017-01-29 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC