ID:               33006
 User updated by:  billy dot becker at gmail dot com
 Reported By:      billy dot becker at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Variables related
 Operating System: gentoo linux 2.4.28-gentoo-r2
 PHP Version:      5.0.3
 New Comment:

I am retarded. I didn't fully understand magic quotes until i reread
the manual. GPC magic quotes was set to on, and so all my NULLS (0x00)
were getting escaped. I turned GPC magic quotes off in my php.ini and
tested it and $_POST['message'] was not corrupt.

I'm setting this bug to bogus now.

Obligatory "RTFM" accepted.


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

[2005-05-11 08:19:03] billy dot becker at gmail dot com

Description:
------------
I have a form that submits a wavfile as a variable. The form uses
enctype application/form-data-urlencoded. Normal variables (integer and
string) get tranmitted fine and I can access them normally from $_POST.

However, my wavfile is coming through corrupt. The bug is that although
the documentation says that PHP does only a urldecode before populating
the $_POST array, something else must be happening in addition.

However, If I manually parse the $HTTP_RAW_POST_DATA string, I can pull
my data out, urldecode() it, and the data is fine. When I compare the
urldecoded RAW_POST_DATA to the $_POST data, I find that the $_POST
data has man low-bit characters replaced with high-bit characters, and
the $_POST data has about 200bytes of extra information strewn
throughout the string. 

So, the data is getting transmitted to the server fine, and PHP see's
it fine, but it does something when it puts it into the $_POST array to
corrupt the data.

I started a thread on comp.lang.php named "how does PHP5 process POST
data in creating $_POST array?"
this link may or may not work:
http://groups-beta.google.com/group/comp.lang.php/browse_frm/thread/01636851f3909135/22e6b7fa4724b4e6#22e6b7fa4724b4e6

I'm not sure how you will be able to reproduce the error without having
access to a source that will send wav data as a form variable. 

Let me know if there is anything else I can do or give you to help fix
this bug.

Reproduce code:
---------------
Assuming you have a source that has posted a wav file with the variable
name: message

this code will show you the difference:

function &parse_http_raw_post_data(&$data, $split1str = '&', $split2str
= '=')
       {
           $split1dat = explode($split1str, $data);
           $num = count($split1dat);
           
           if (! $num) { return false; }
           
           for ($i = 0; $i < $num; $i++) {
               $split2dat=explode($split2str, $split1dat[$i]);
               $ret[$split2dat[$i]] = $split2dat[$i + 1];
           }
           return $ret;
       }

$rawdata=$HTTP_RAW_POST_DATA;
$parsedata=parse_http_raw_post_data($rawdata);
$wavdata=$parsedata['message'];

$postdata=$_POST['message'];

file_put_contents("$writepath/$filename-raw.wav", $wavdata);
file_put_contents("$writepath/$filename-post.wav", $postdata);
file_put_contents("$writepath/$filename-u.wav",  
urldecode($wavdata));


Expected result:
----------------
wavdata and postdata should be exactly the same.

Actual result:
--------------
wavdata contains: RIFFFóWAVEfmt @data óÿþÿÿÿÿÿþÿÿÿÿÿþ....

postdata contains: RIFFFó\0\0WAVEfmt [EMAIL PROTECTED]@\0\0\\0\0\0data
ó\....

there's a lot more to the output, but that's the gist of it. PHP is
inserting lots of \0 where it doesn't need to be.

I can send you the two files to compare if you wish.


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


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

Reply via email to