Bug #11516 Updated: multipart/form-data doesn't accept a NULL character
| From: | andy@php.net | Date: | Sun, 22 Jul 2001 17:18:02 +0000 |
| Subject: | Bug #11516 Updated: multipart/form-data doesn't accept a NULL character | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-60649@lists.php.net to get a copy of this message | ||
ID: 11516
Updated by: andy
Reported By: jeroen@smartnet.dhs.org
Old Status: Feedback
Status: Closed
Bug Type: Variables related
Operating System: winnt4.0
PHP Version: 4.0.5
New Comment:
no feedback after 30+ days.
Previous Comments:
------------------------------------------------------------------------
[2001-06-17 13:53:46] sniper@php.net
This works for me just fine. Could you please try
the latest snapshot from http://www.zend.com/snapshots/
------------------------------------------------------------------------
[2001-06-16 19:37:27] jeroen@smartnet.dhs.org
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 this bug report at http://bugs.php.net/?id=11516&edit=1