diff --git a/lib/Cake/Network/Http/HttpSocketResponse.php b/lib/Cake/Network/Http/HttpSocketResponse.php index ceaaf3074..40bef3973 100644 --- a/lib/Cake/Network/Http/HttpSocketResponse.php +++ b/lib/Cake/Network/Http/HttpSocketResponse.php @@ -319,7 +319,11 @@ class HttpSocketResponse implements ArrayAccess { $parts = preg_split('/\;[ \t]*/', $cookie); } - list($name, $value) = explode('=', array_shift($parts), 2); + $nameParts = explode('=', array_shift($parts), 2); + if (count($nameParts) < 2) { + $nameParts = array('', $nameParts[0]); + } + list($name, $value) = $nameParts; $cookies[$name] = compact('value'); foreach ($parts as $part) { diff --git a/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php b/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php index 2fde8eb5e..4127dfc96 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php @@ -480,7 +480,9 @@ class HttpResponseTest extends CakeTestCase { 'Set-Cookie' => array( 'foo=bar', 'people=jim,jack,johnny";";Path=/accounts', - 'google=not=nice' + 'google=not=nice', + '1271; domain=.example.com; expires=Fri, 04-Nov-2016 12:50:26 GMT; path=/', + 'cakephp=great; Secure' ), 'Transfer-Encoding' => 'chunked', 'Date' => 'Sun, 18 Nov 2007 18:57:42 GMT', @@ -496,17 +498,24 @@ class HttpResponseTest extends CakeTestCase { ), 'google' => array( 'value' => 'not=nice', + ), + '' => array( + 'value' => '1271', + 'domain' => '.example.com', + 'expires' => 'Fri, 04-Nov-2016 12:50:26 GMT', + 'path' => '/' + ), + 'cakephp' => array( + 'value' => 'great', + 'secure' => true, ) ); $this->assertEquals($expected, $cookies); - $header['Set-Cookie'][] = 'cakephp=great; Secure'; - $expected['cakephp'] = array('value' => 'great', 'secure' => true); - $cookies = $this->HttpResponse->parseCookies($header); - $this->assertEquals($expected, $cookies); - $header['Set-Cookie'] = 'foo=bar'; - unset($expected['people'], $expected['cakephp'], $expected['google']); + $expected = array( + 'foo' => array('value' => 'bar') + ); $cookies = $this->HttpResponse->parseCookies($header); $this->assertEquals($expected, $cookies); }