php.net |  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
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: wangyi6854 at sohu dot com
New email:
PHP Version: OS:

 

 [2010-12-15 09:04 UTC] wangyi6854 at sohu dot com
Description:
------------
curl post will failed when post field's first char is '@'.

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

Test script:
---------------
<?php
$msg = '';
if ( !empty( $_POST ) ) {
	$ch = curl_init();
	curl_setopt( $ch, CURLOPT_URL, "http://192.0.32.10/" );
	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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head></head>
<body>
<pre><?php echo $msg; ?></pre>
<form method="post" action="">
	<input type="submit" name="test" value="test!" />
</form>
</body></html>


Expected result:
----------------
curl should work whatever the content is.

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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-15 09:19 UTC] aharvey@php.net
-Status: Open +Status: Bogus
 [2010-12-15 09:19 UTC] aharvey@php.net
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
Yes.

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?

Thanks!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC