|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53548 post failled when '@' is the first character
Submitted: 2010-12-15 09:04 UTC Modified: 2010-12-15 09:19 UTC
From: wangyi6854 at sohu dot com Assigned:
Status: Not a bug Package: cURL related
PHP Version: 5.3.4 OS: FreeBSD 8.1
Private report: No CVE-ID: None
 [2010-12-15 09:04 UTC] wangyi6854 at sohu dot com
curl post will failed when post field's first char is '@'.

the ip address in the following code is's. You can replace it with any address.

Test script:
$msg = '';
if ( !empty( $_POST ) ) {
	$ch = curl_init();
	curl_setopt( $ch, CURLOPT_URL, "" );
	curl_setopt( $ch, CURLOPT_POST, 1 );
	curl_setopt( $ch, CURLOPT_POSTFIELDS, array( 'test' => '@aaaa' ) );

	if ( false === curl_exec( $ch ) ) {
		$msg .= 'curl error: ' . curl_errno( $ch ) . ".\nmessage: " . curl_error( $ch ) . PHP_EOL;
	else {
		$msg .= 'OK!';
	curl_close( $ch );
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<pre><?php echo $msg; ?></pre>
<form method="post" action="">
	<input type="submit" name="test" value="test!" />

Expected result:
curl should work whatever the content is.

Actual result:
curl will failed when post field's first char is '@'.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-15 09:19 UTC]
-Status: Open +Status: Bogus
 [2010-12-15 09:19 UTC]
As documented on the curl_setopt() manual page, CURLOPT_POSTFIELDS will
assume that a value starting with @ is the location of a file to use as
the post data, and not the literal post data itself.
 [2010-12-15 09:29 UTC] wangyi6854 at sohu dot com

But curl should provide a option to turn it off. The project I involve limits the length of post field. So add some char into the front of the string is not possible. 

I check the curl's manual(command line version). it has a global option to turn it off. But I can't found the way to turn off some particular fields.

Any suggestion?

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Mar 07 15:01:23 2021 UTC