#44050 [Bgs]: Multiple 'Cookie: ' headers incorrectly parsed
| From: | rasmus@php.net | Date: | Thu, 07 Feb 2008 09:05:47 +0000 |
| Subject: | #44050 [Bgs]: Multiple 'Cookie: ' headers incorrectly parsed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-122063@lists.php.net to get a copy of this message | ||
ID: 44050
Updated by: rasmus@php.net
Reported By: a dot candle at gmail dot com
Status: Bogus
Bug Type: Unknown/Other Function
Operating System: slackware/debian
PHP Version: 5.2.5
New Comment:
I am curious, which client/browser are you using that is sending back
this $Version=0; stuff when that isn't in your original setcookie()
call? That seems very odd to me.
Previous Comments:
------------------------------------------------------------------------
[2008-02-06 18:49:48] jani@php.net
See also Feature request http://bugs.php.net/bug.php?id=32860
------------------------------------------------------------------------
[2008-02-06 18:37:52] msaraujo@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
Hello,
Please check the following report:
http://bugs.php.net/bug.php?id=32827
Thanks
------------------------------------------------------------------------
[2008-02-05 21:53:47] pfx-bugs dot php dot net at goeswhere dot com
This can be reproduced by, for example (with the above test-case as
http://localhost/pro.php):
faux@jimi:~% echo -e 'GET /pro.php HTTP/1.1\r\nHost:
localhost\r\nCookie: $Version=0; a=aaaa\r\nCookie: $Version=0;
b=bbbb\r\nCookie: $Version=0; c=bbbb\r\nConnection: close\r\n' | nc
localhost 80
HTTP/1.1 200 OK
Date: Tue, 05 Feb 2008 21:51:41 GMT
Server: Apache/2.2.3 (Debian) PHP/5.2.0-8+etch10
X-Powered-By: PHP/5.2.0-8+etch10
Set-Cookie: a=aaaa
Set-Cookie: b=bbbb
Set-Cookie: c=cccc
Content-Length: 160
Connection: close
Content-Type: text/html; charset=UTF-8
array(4) {
["$Version"]=>
string(1) "0"
["a"]=>
string(16) "aaaa, $Version=0"
["b"]=>
string(16) "bbbb, $Version=0"
["c"]=>
string(4) "bbbb"
}
faux@jimi:~%
------------------------------------------------------------------------
[2008-02-05 20:31:59] msaraujo@php.net
Hello,
I have not been able to reproduce your issue. Can you please give us
more feedback about that?
------------------------------------------------------------------------
[2008-02-05 17:37:48] a dot candle at gmail dot com
Description:
------------
When a client sends multiple 'Cookie' headers they appear to be parsed
incorrectly.
What I believe is happening is that the value part of the cookie
headers (after the ': ') are being concaternated with a comma rather
then a semicolon. Then (as per the cookie spec:
http://wp.netscape.com/newsref/std/cookie_spec.html)
the resulting
string is being split on semicolon, resulting in the broken cookie
values.
Reproduce code:
---------------
php code:
<?php
setcookie("a", "aaaa");
setcookie("b", "bbbb");
setcookie("c", "cccc");
var_dump($_COOKIE);
?>
headers sent by client: (on the second request)
"Cookie: $Version=0; a=aaaa\r\n"
"Cookie: $Version=0; b=bbbb\r\n"
"Cookie: $Version=0; c=bbbb\r\n"
Expected result:
----------------
array(4) {
["$Version"]=>
string(1) "0"
["a"]=>
string(4) "aaaa"
["b"]=>
string(4) "bbbb"
["c"]=>
string(4) "cccc"
}
Actual result:
--------------
resulting output:
array(4) {
["$Version"]=>
string(1) "0"
["a"]=>
string(16) "aaaa, $Version=0"
["b"]=>
string(16) "bbbb, $Version=0"
["c"]=>
string(4) "cccc"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44050&edit=1