Req #51633 [NEW]: Accept "post" input of multiple fields with the same name

From: Date: Thu, 22 Apr 2010 12:49:58 +0000
Subject: Req #51633 [NEW]: Accept "post" input of multiple fields with the same name
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-149784@lists.php.net to get a copy of this message
From:             
Operating system: Ubuntu
PHP version:      5.2.13
Package:          HTTP related
Bug Type:         Feature/Change Request
Bug description:Accept "post" input of multiple fields with the same name

Description:
------------
I currently have to handle post data which is submitted as
multipart/form-data and has multiple fields with the same name. The latter
means I can't use $_POST (I only get the last of the fields with the same
name) and the former means I can't use php://input or $HTTP_RAW_POST_DATA.

According to http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.1.2.3
it's fine to have multiple fields with the same name.

The obvious answer to my problem would be to append "[]" to the end of the
field names so that PHP parses them into an array. But in this case I don't
have control over the data source.

And in fact the HTML4.01 specification says at
http://www.w3.org/TR/html4/types.html#h-6.2
'ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed
by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
colons (":"), and periods (".")'
So putting "[]" at the end of field names is actually against the HTML
specification so it seems bad to require them.

So I have two suggestions here (let me know if I should file a separate
request for the latter):

1. Whenever there is more than one field with the same name make an array,
rather than only when the field name ends in "[]". This could of course
cause issues with existing scripts which are being passed multiple values
when they don't expect it or which are relying on a later field with the
same name overwriting an earlier one, but I would wager that this is rare.

2. I could work around this right now if I could get php://input or
$HTTP_RAW_POST_DATA, only they're not available since it's
multipart/form-data. Why shouldn't the raw post data be available when it's
encoded this way? It'd make it possible to work around broken post data (in
this case as far as I can see the post data is fine according to the spec
but I can imagine having to deal with actual broken data).


-- 
Edit bug report at http://bugs.php.net/bug.php?id=51633&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=51633&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=51633&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=51633&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=51633&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51633&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=51633&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=51633&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=51633&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=51633&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=51633&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=51633&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=51633&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=51633&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=51633&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51633&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51633&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=51633&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=51633&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=51633&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=51633&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=51633&r=mysqlcfg



Thread (7 messages)

« previous php.bugs (#149784) next »