Support for non-valid cookie values, fixes #6327

This commit is contained in:
the_undefined 2009-05-04 21:53:39 +02:00
parent f0879f96ed
commit 94c01ac7b4
2 changed files with 8 additions and 4 deletions

View file

@ -846,7 +846,7 @@ class HttpSocket extends CakeSocket {
$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) {

View file

@ -1156,7 +1156,8 @@ class HttpSocketTest extends CakeTestCase {
$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 @@ class HttpSocketTest extends CakeTestCase {
),
'people' => array(
'value' => 'jim,jack,johnny";"',
'path' => '/accounts'
'path' => '/accounts',
),
'google' => array(
'value' => 'not=nice',
)
);
$this->assertEqual($cookies, $expected);
@ -1179,7 +1183,7 @@ class HttpSocketTest extends CakeTestCase {
$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);
}