php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55504 Content-Type header is not parsed correctly on HTTP POST request
Submitted: 2011-08-25 06:18 UTC Modified: 2011-09-07 16:19 UTC
From: mumu at seznam dot cz Assigned: bjori (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 5.3.8 OS: FreeBSD, Windows Server 2008
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mumu at seznam dot cz
New email:
PHP Version: OS:

 

 [2011-08-25 06:18 UTC] mumu at seznam dot cz
Description:
------------
HTTP POST is not parsed correctly when the "boundary" parameter of the Content-Type HTTP header is not the last parameter on the line.

---

Guessing (might be wrong):
In the first case, PHP parses the ";" (and maybe also the rest of the line)
after the boundary still as part of the boundary value. As a result, the POST
DATA are not "understood" correctly. However, the following parts from RFC 1521
states clearly that ";" could not be part of the boundary:
tspecials :=  "(" / ")" / "<" / ">" / "@"
                /  "," / ";" / ":" / "\" / <">
                /  "/" / "[" / "]" / "?" / "="
               ; Must be in quoted-string,
               ; to use within parameter values

boundary := 0*69<bchars> bcharsnospace
bchars := bcharsnospace / " "
bcharsnospace :=    DIGIT / ALPHA / "'" / "(" / ")" / "+" /"_"
                 / "," / "-" / "." / "/" / ":" / "=" / "?"

Test script:
---------------
Consider the following call to a PHP script running on an Apache server.
Connection: Keep-Alive
Content-Type: multipart/form-data; boundary=BVoyv; charset=iso-8859-1
Accept: */*
Content-Length: 72
Host: example.com

Content-Disposition: form-data; name="data"

abc
--BVoyv--

And a corresponding PHP script:
<?php
  print_r(getallheaders());
  print_r($_REQUEST);
?>

In this case, the POST data are not seen on the PHP side, as shown on the
output:
Array
(
    [Connection] => Keep-Alive
    [Content-Type] => multipart/form-data; boundary=BVoyv; charset=iso-8859-1
    [Accept] => */*
    [Content-Length] => 72
    [Host] => example.com
)
Array
(
)

However, after changing order of parameters in the Content-Type header to:
"Content-Type: multipart/form-data; charset=iso-8859-1; boundary=BVoyv"
the script output is as expected (notify appearing of the [data] line):
Array
(
    [Connection] => Keep-Alive
    [Content-Type] => multipart/form-data; charset=iso-8859-1; boundary=BVoyv
    [Accept] => */*
    [Content-Length] => 72
    [Host] => example.com
)
Array
(
    [data] => abc
)



Expected result:
----------------
Both cases should be equal to each other.

Actual result:
--------------
In the first case, the "data" parameter is not available to the script.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-26 07:15 UTC] mumu at seznam dot cz
The test call in the original comment is not correct. It should state:
Content-Type: multipart/form-data; boundary=BVoyv; charset=iso-8859-1
Accept: */*
Content-Length: 72
Host: example.com

--BVoyv
Content-Disposition: form-data; name="data"

abc
--BVoyv--
 [2011-09-07 15:55 UTC] bjori@php.net
-Assigned To: +Assigned To: bjori
 [2011-09-07 16:18 UTC] bjori@php.net
Automatic comment from SVN on behalf of bjori
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=316373
Log: Fixed bug #55504 (Content-Type header is not parsed correctly on HTTP POST request
 [2011-09-07 16:19 UTC] bjori@php.net
-Status: Assigned +Status: Closed
 [2011-09-07 16:19 UTC] bjori@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-04-18 09:49 UTC] laruence@php.net
Automatic comment on behalf of bjori
Revision: http://git.php.net/?p=php-src.git;a=commit;h=994df9f1d1bfd5f6e6b81f32161acc2812d260a7
Log: Fixed bug #55504 (Content-Type header is not parsed correctly on HTTP POST request
 [2012-07-24 23:40 UTC] rasmus@php.net
Automatic comment on behalf of bjori
Revision: http://git.php.net/?p=php-src.git;a=commit;h=994df9f1d1bfd5f6e6b81f32161acc2812d260a7
Log: Fixed bug #55504 (Content-Type header is not parsed correctly on HTTP POST request
 [2013-11-17 09:36 UTC] laruence@php.net
Automatic comment on behalf of bjori
Revision: http://git.php.net/?p=php-src.git;a=commit;h=994df9f1d1bfd5f6e6b81f32161acc2812d260a7
Log: Fixed bug #55504 (Content-Type header is not parsed correctly on HTTP POST request
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC