php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55767 CURLOPT_POSTFIELDS Ignores Numeric Field Names
Submitted: 2011-09-23 07:41 UTC Modified: 2011-09-23 13:21 UTC
From: brad at hostland dot com Assigned: rasmus (profile)
Status: Closed Package: cURL related
PHP Version: 5.3.8 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: brad at hostland dot com
New email:
PHP Version: OS:

 

 [2011-09-23 07:41 UTC] brad at hostland dot com
Description:
------------
If you use a numeric array key to represent a numeric field name, cURL will ignore the field completely when submitting the POST.

For example, suppose you have an HTML form containing a field named 'somefield' and another field named '100'. We want to simulate submitting this form using cURL:

When the script below is executed, cURL will submit the form and pass the 'somefield' data, but will completely ignore the '100' data in the form post.

$ch = curl_init('http://www.someurl.com');
curl_setopt($ch, CURLOPT_POST, 1);
$fields['somefield'] = 'Some Data';
$fields['100'] = 'Some Other Data';
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$output = curl_exec($ch);

Test script:
---------------
$ch = curl_init('http://www.someurl.com');
curl_setopt($ch, CURLOPT_POST, 1);
$fields['somefield'] = 'Some Data';
$fields['100'] = 'Some Other Data';
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$output = curl_exec($ch);


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-23 13:16 UTC] rasmus@php.net
Automatic comment from SVN on behalf of rasmus
Revision: http://svn.php.net/viewvc/?view=revision&revision=317201
Log: Fix for bug #55767
 [2011-09-23 13:21 UTC] rasmus@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: rasmus
 [2011-09-23 13:21 UTC] rasmus@php.net
Fixed in 5.4 and trunk. Need to have a closer look to see if it might be a BC 
break in 5.3
 [2011-09-23 22:41 UTC] brad at hostland dot com
Is there any way this can be fixed in 5.3? This is causing me big problems and I'm unable to install 5.4 at this time.
 [2011-10-22 14:39 UTC] mat999 at gmail dot com
seconded, I cant see any reason for it to be a BC break either.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 07:01:31 2024 UTC