From:             [EMAIL PROTECTED]
Operating system: winnt4.0
PHP version:      4.0.5
PHP Bug Type:     Variables related
Bug description:  multipart/form-data doesn't accept a NULL character

Hi,


first of all, I'm not 100% sure this is a bug, but I think it is. anyway, here goes:

I manually connect to a php script, by simulating a browser's call. I want to sent 
some data by simulating a multipart/form-data POST. The data I sent is binary, but 
since I want to put this data directly into a database, I don't want to use the 
Content-Disposition: form-data; name="whatever"; filename="C:\whatever.exe" header.

This header would cause php to create a file in the tmp dir, and I don't want this. I 
simply want the binary data I send in a variable.

What I did was to set the following header: Content-Disposition: form-data; 
name="whatever"
(without the filename="C:\whatever.exe" part). After that I sent the binary data.

This should create a variable $whatever on the server. 
Everything works just fine until my binary data contains a NULL [chr(0)]. What happens 
is that php creates the variable $whatever, but truncates everything after the NULL 
character (including the NULL character itself).

Of course you wouldn't be able to send a NULL from a normal multipart form input box 
or textarea on the web, but I think php should be able to create a variable which 
contains my NULL character and everything that follows when I manually connect. It 
correctly creates a file (including the NULL) when I sent the 'filename="whatever"' 
header.

By the way, if my form contains more parts after the binary part with the NULL 
character, php creates those variables correctly... but it just truncates everything 
after a NULL when I don't send something like filename="c:\whatever.exe".

here is a copy of the headers I manually sent:
****START****
POST /script.php HTTP/1.1
Content-Type: multipart/form-data; boundary=---------------------------7d12b732260086
Host: www.myserver.com
Content-Length: [The correct length]

-----------------------------7d12b732260086
Content-Disposition: form-data; name="whatever"

123[NULL]456
-----------------------------7d12b732260086
Content-Disposition: form-data; name="foo"

normal text, not binary
-----------------------------7d12b732260086--
****END****

my script on the server now has 2 variables; $whatever and $foo.
print $foo; #this prints "normal text, not binary"
print $whatever; #this prints "123". it should have printed "123 456" (the space here 
simulating the unprintable NULL character)


I hope this all makes sense (I'm not sure it does :) ). But please email me if this 
message is not completely clear.

I hope you get back to me.


thanks in advance
Jeroen


-- 
Edit Bug report at: http://bugs.php.net/?id=11516&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