Permalink
Browse files

Support for non-valid cookie values, fixes #6327

  • Loading branch information...
1 parent f0879f9 commit 94c01ac7b443869c4f2e4a0507f36485e71f5615 @felixge felixge committed May 4, 2009
Showing with 8 additions and 4 deletions.
  1. +1 −1 cake/libs/http_socket.php
  2. +7 −3 cake/tests/cases/libs/http_socket.test.php
@@ -846,7 +846,7 @@ function parseCookies($header) {
$cookies = array();
foreach ((array)$header['Set-Cookie'] as $cookie) {
$parts = preg_split('/(?<![^;]");[ \t]*/', $cookie);
- list($name, $value) = explode('=', array_shift($parts));
+ list($name, $value) = explode('=', array_shift($parts), 2);
$cookies[$name] = compact('value');
foreach ($parts as $part) {
if (strpos($part, '=') !== false) {
@@ -1156,7 +1156,8 @@ function testParseCookies() {
$header = array(
'Set-Cookie' => array(
'foo=bar',
- 'people=jim,jack,johnny";";Path=/accounts'
+ 'people=jim,jack,johnny";";Path=/accounts',
+ 'google=not=nice'
),
'Transfer-Encoding' => 'chunked',
'Date' => 'Sun, 18 Nov 2007 18:57:42 GMT',
@@ -1168,7 +1169,10 @@ function testParseCookies() {
),
'people' => array(
'value' => 'jim,jack,johnny";"',
- 'path' => '/accounts'
+ 'path' => '/accounts',
+ ),
+ 'google' => array(
+ 'value' => 'not=nice',
)
);
$this->assertEqual($cookies, $expected);
@@ -1179,7 +1183,7 @@ function testParseCookies() {
$this->assertEqual($cookies, $expected);
$header['Set-Cookie'] = 'foo=bar';
- unset($expected['people'], $expected['cakephp']);
+ unset($expected['people'], $expected['cakephp'], $expected['google']);
$cookies = $this->Socket->parseCookies($header);
$this->assertEqual($cookies, $expected);
}

0 comments on commit 94c01ac

Please sign in to comment.