Bug #66436 [NEW]: CURLOPT_POSTFIELDS duplicate field names

From: Date: Tue, 07 Jan 2014 16:50:44 +0000
Subject: Bug #66436 [NEW]: CURLOPT_POSTFIELDS duplicate field names
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183629@lists.php.net to get a copy of this message
From: julian at julianrhindconsulting dot com Operating system: any PHP version: 5.5.7 Package: cURL related Bug Type: Bug Bug description:CURLOPT_POSTFIELDS duplicate field names Description: ------------ Hi There appears to be a problem with the current curl implementation in regard to duplicate post fields - especially when also wanting to post files In order to call curl_setopt option CURLOPT_POSTFIELDS with the following data name=Bob name=Mary this can be done using the string form passing 'name=Bob&name=Mary' however it can't be done using the array form ['name'=>'Bob', 'name'=>'Mary'] for obvious reasons When posting files it appears to be a requirement to use the array form So what is one to do - if one wants to post duplicate field names and files? This bug/design problem appears to be long standing and is inquired widely on the internet - however no one appears to be trying to resolve it Is it possible this could be resolved? The simplest solution would appear to be to handle a field name pointing to an array as a duplicate field name - so one would specify [name=>['Bob','Mary']] and curl_setopt would generate name=Bob&name=Mary I also note that this exact problem occurs when receiving posted data via $_POST - again the same solution could be used - duplicate posted fields would return an array rather than a single value I'm also aware of a workaround - using ['name[0]'=>'Bob','name[1]'=>'Mary'] however this does not generate the correct post data - but may be understood by the server if it happens to be running PHP Regards Julian Julian Rhind Expected result: ---------------- name=Bob&name=Mary Actual result: -------------- name=Mary -- Edit bug report at https://bugs.php.net/bug.php?id=66436&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66436&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66436&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66436&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=66436&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=66436&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=66436&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=66436&r=needscript Try newer version: https://bugs.php.net/fix.php?id=66436&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=66436&r=support Expected behavior: https://bugs.php.net/fix.php?id=66436&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=66436&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=66436&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=66436&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66436&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=66436&r=dst IIS Stability: https://bugs.php.net/fix.php?id=66436&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=66436&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=66436&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=66436&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=66436&r=mysqlcfg

« previous php.bugs (#183629) next »