Support for non-valid cookie values, fixes #6327

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8164 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2009-05-04 20:13:10 +00:00
parent cf3f92c402
commit be7ade3a4c
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);
}