ID: 14321
User updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Bogus
Bug Type: Variables related
Operating System: i686-gnu-linux
PHP Version: 4.1.0
Old Assigned To: sterling
Assigned To: 
New Comment:

Ok, I tried $HTTP_RAW_POST_DATA.
The result of "echo rawurlencode($HTTP_RAW_POST_DATA);" is :
#####
--curl0m0Kw3o0o1CufhI8a%2BHAFaguSrD%0D%0A
Content-Disposition%3A%20form-data%3B%20name%3D%22BinaryData%22%0D%0A%0D%0A
A%00B%0D%0A
--curl0m0Kw3o0o1CufhI8a%2BHAFaguSrD--%0D%0A
#####
So it seems that PHP receives the data (A%00B) correctly.
But why doesn't $_POST reveal the same data ?
Is there something wrong with reassembling the data
of the post in PHP (maybe in rfc1867.c) ?
Or is there another way of getting the data w/o the rfc1867 stuff (e.g. boundaries) 
besides "$_POST" ?

Hanno

Previous Comments:
------------------------------------------------------------------------

[2001-12-13 06:45:23] [EMAIL PROTECTED]

Try $HTTP_RAW_POST_DATA. Encode data with base64 or like when you print, if there is 
null char in data. Then you should be able to deal with.

------------------------------------------------------------------------

[2001-12-13 05:31:15] [EMAIL PROTECTED]

Sorry, this is not a bogus.
I wish it was. Obviously Sterling got me completely wrong.
It's not a problem of printing binary data.
As I do not use curl with PHP this bug is NOT Curl related it's more in the receiving 
end.
What I'm doing is posting binary data using
libcurl with c++.
In this example it's a buffer containing A,chr(0) and B.
Network traces show the following:
########
POST /test.php HTTP/1.1.
Pragma: no-cache.
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*.
Content-Length: 130.
Content-Type: multipart/form-data; boundary=curl/49TVuznugm1TDG2p68EyKJrXOq.
.
--curl/49TVuznugm1TDG2p68EyKJrXOq.
Content-Disposition: form-data; name="BinaryData".
.
A.B.
--curl/49TVuznugm1TDG2p68EyKJrXOq--.
########
I hope everybody agrees that the post is ok and that
it's containing 3 byte of data (A,chr(0) and B). 
So I do not present the C++ code here, as it is obviously not relevant.
On the PHP side I check the received data with:
########
echo "POST: ";
print_r($_POST);
//and just to make sure print_r is binary safe...
$foo="X".chr(0)."Z"; 
print_r($foo);
########
the result is:
########
POST: Array
(
     [BinaryData] => A
)
X.Z
########
So everything following "A" including chr(0) has been truncated.
Again this problem has been mentioned on 2001-06-16 by [EMAIL PROTECTED] in bug 
report #11516.

Additionally if I change the name of the post variable to 
###
name="BinaryData" filename="foo"
###
to trick PHP into believing it's a ordinary file post
the received file contains all the 3 bytes.
This should prove that the post itself is ok.
Tell me if you want me to present the c source code or
do some different kind of testing.
Tests were done with PHP 4.1.0 and the latest CVS version.
Hanno 


------------------------------------------------------------------------

[2001-12-03 09:36:46] [EMAIL PROTECTED]

a) not a cURL related bug report
b) bogus, when you print binary data, expect it to be truncated at the NULL, this is 
the same in every language.

------------------------------------------------------------------------

[2001-12-03 06:23:56] [EMAIL PROTECTED]

Assigning to sterling, the cURL master.

Derick

------------------------------------------------------------------------

[2001-12-03 06:22:04] [EMAIL PROTECTED]

This one is related to the report of [EMAIL PROTECTED] (Bug id #11516).
I talked to sniper about this problem a year ago, but I could not convince him that 
this behaviour of PHP to truncate post variables at the first occurrance of 0x00 
exists and that it's incorrect (when used with multipart-formdata). Some days ago I 
used libCURL with C++ to post binary data with the "CURLFORM_PTRCONTENTS" option which 
lead to the same problem. Packet-sniffing revealed that the data is sent correctly, 
but PHP truncates the variable at the first occurance of 0x00. I had a discussion with 
Daniel Stenberg (Curl-developer) on that topic. He agreed that following RFC1867 it is 
allowed to send binary data in the way jeroen describes and he was pretty much 
suprised that PHP causes such problems. As the function curl_formadd() and 
"CURLOPT_POSTFIELDSIZE" is not implemented in PHP I can not give you a PHP script 
which produces the error but let me know if you're interested in an example written in 
C++. I would appriciate very much if this bug could be removed in future versions of 
PHP.
thanks in advance
Hanno




------------------------------------------------------------------------



Edit this bug report at http://bugs.php.net/?id=14321&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to