Bug #11516: multipart/form-data doesn't accept a NULL character
| From: | jeroen at smartnet dot dhs dot org | Date: | Sat, 16 Jun 2001 23:37:27 +0000 |
| Subject: | Bug #11516: multipart/form-data doesn't accept a NULL character | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-56888@lists.php.net to get a copy of this message | ||
From: jeroen@smartnet.dhs.org
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