ID:               48190
 User updated by:  carsten_sttgt at gmx dot de
 Reported By:      carsten_sttgt at gmx dot de
 Status:           Open
 Bug Type:         HTTP related
 Operating System: Windows NT
 PHP Version:      5.*CVS, 6CVS (2009-05-08)
 New Comment:

> Just curious, but what client actually uses
> uppercase/mixed case "boundary" parameter name?

I'm using imap_mail_compose() to build the 'header' and 'content' keys
in the stream_context_create() options array. And then using this
context with e.g. file_get_contents() to make the POST request.

BTW: The above example is a HTTP POST request without a file upload.


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

[2009-05-08 22:05:58] j...@php.net

Just curious, but what client actually uses uppercase/mixed case 
"boundary" parameter name? (and 

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

[2009-05-08 21:41:55] carsten_sttgt at gmx dot de

In my first post I have refereed to RFC2045, but RFC2616 is also very
clear about this [1]:
| The type, subtype, and parameter attribute names are
| case- insensitive. Parameter values might or might
| not be case-sensitive, depending on the semantics
| of the parameter name.

type = MULTIPART
subtype = form-data
parameter attribute name = BOUNDARY
parameter value = 250-16659-1241787336=:9320

[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7

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

[2009-05-08 13:46:57] carsten_sttgt at gmx dot de

Description:
------------
Hello,

PHP does not work correctly with POST requests and a Content-Type of
MULTIPART/form-data, if the parameter name "BOUNDARY" is in uppercase.

According to RFC2045, matching of media type, subtype and parameter
(attributes) is always case-insensitive.

(only the value of the BOUNDARY parameter is compared case-sensitive)

Tested on Windows with 5.2-dev, 5.3-dev and 6.0-dev. CGI and Apache
module.

Regards,
Carsten



Reproduce code:
---------------
Put this textfile in your PHP directory:
**************** test.txt ******************
--250-16659-1241787336=:9320
Content-Type: TEXT/plain; CHARSET=iso-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE
Content-Disposition: form-data; name=nick

php-faq
--250-16659-1241787336=:9320
Content-Type: TEXT/plain; CHARSET=iso-8859-1
Content-Transfer-Encoding: QUOTED-PRINTABLE
Content-Disposition: form-data; name=desc

post demo script
--250-16659-1241787336=:9320--
********************************************

Put this phpfile in your PHP directory:
**************** test.php ******************
<?php
var_dump($_POST);
?>
********************************************

Open a command prompt, go to your PHP dir and execute:
# set REQUEST_METHOD=POST
# set REDIRECT_STATUS=1
# set SCRIPT_FILENAME=test.php
# set CONTENT_LENGTH=391
# set CONTENT_TYPE=MULTIPART/form-data;
BOUNDARY="250-16659-1241787336=:9320"
# type test.text | php-cgi.exe

if you set CONTENT_TYPE in this way, you have the correct result:
# set CONTENT_TYPE=MULTIPART/form-data;
boundary="250-16659-1241787336=:9320"

Regards,
Carsten

BTW:
e.g. the IMAP-Module from PHP is using/generating BOUNDARY in
uppercase.


Expected result:
----------------
Content-type: text/html

array(2) {
  ["nick"]=>
  string(7) "php-faq"
  ["desc"]=>
  string(16) "post demo script"
}


Actual result:
--------------
Content-type: text/html

<br />
<b>Warning</b>:  Missing boundary in multipart/form-data POST data in
<b>Unknown
</b> on line <b>0</b><br />
array(0) {
}



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


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

Reply via email to