Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gwoo committed May 4, 2009
1 parent cf3f92c commit be7ade3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cake/libs/http_socket.php
Expand Up @@ -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) {
Expand Down
10 changes: 7 additions & 3 deletions cake/tests/cases/libs/http_socket.test.php
Expand Up @@ -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',
Expand All @@ -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);
Expand All @@ -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);
}
Expand Down

0 comments on commit be7ade3

Please sign in to comment.