mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Fix HttpSocket emitting errors when nameless cookies are encountered.
Refs #9698
This commit is contained in:
parent
7f0b0739a8
commit
6a201696dd
2 changed files with 21 additions and 8 deletions
|
@ -319,7 +319,11 @@ class HttpSocketResponse implements ArrayAccess {
|
||||||
$parts = preg_split('/\;[ \t]*/', $cookie);
|
$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');
|
$cookies[$name] = compact('value');
|
||||||
|
|
||||||
foreach ($parts as $part) {
|
foreach ($parts as $part) {
|
||||||
|
|
|
@ -480,7 +480,9 @@ class HttpResponseTest extends CakeTestCase {
|
||||||
'Set-Cookie' => array(
|
'Set-Cookie' => array(
|
||||||
'foo=bar',
|
'foo=bar',
|
||||||
'people=jim,jack,johnny";";Path=/accounts',
|
'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',
|
'Transfer-Encoding' => 'chunked',
|
||||||
'Date' => 'Sun, 18 Nov 2007 18:57:42 GMT',
|
'Date' => 'Sun, 18 Nov 2007 18:57:42 GMT',
|
||||||
|
@ -496,17 +498,24 @@ class HttpResponseTest extends CakeTestCase {
|
||||||
),
|
),
|
||||||
'google' => array(
|
'google' => array(
|
||||||
'value' => 'not=nice',
|
'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);
|
$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';
|
$header['Set-Cookie'] = 'foo=bar';
|
||||||
unset($expected['people'], $expected['cakephp'], $expected['google']);
|
$expected = array(
|
||||||
|
'foo' => array('value' => 'bar')
|
||||||
|
);
|
||||||
$cookies = $this->HttpResponse->parseCookies($header);
|
$cookies = $this->HttpResponse->parseCookies($header);
|
||||||
$this->assertEquals($expected, $cookies);
|
$this->assertEquals($expected, $cookies);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue