Skip to content

Commit c7704be

Browse files
committed
Fix cookie decryption when using psr7
1 parent 37b9149 commit c7704be

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/Http/ResponseTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected static function parseCookies(array $cookieHeader)
101101
}
102102

103103
list($name, $value) = explode('=', array_shift($parts), 2);
104-
$parsed = compact('name', 'value');
104+
$parsed = compact('name') + ['value' => urldecode($value)];
105105

106106
foreach ($parts as $part) {
107107
if (strpos($part, '=') !== false) {

tests/TestCase/TestSuite/CookieEncryptedUsingControllerTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ public function setUp()
4343
DispatcherFactory::add('ControllerFactory');
4444
}
4545

46+
/**
47+
* tear down.
48+
*
49+
* @return void
50+
*/
51+
public function tearDown()
52+
{
53+
parent::tearDown();
54+
$this->_useHttpServer = false;
55+
}
56+
4657
/**
4758
* Can encrypt/decrypt the cookie value.
4859
*/
@@ -140,4 +151,14 @@ public function testCanAssertCookieEncryptedWithAnotherEncryptionKey()
140151
$this->get('/cookie_component_test/set_cookie');
141152
$this->assertCookieEncrypted('abc', 'NameOfCookie', 'aes', $key);
142153
}
154+
155+
/**
156+
* Can AssertCookie even if encrypted with the aes when using PSR7 server.
157+
*/
158+
public function testCanAssertCookieEncryptedWithAesWhenUsingPsr7()
159+
{
160+
$this->_useHttpServer = true;
161+
$this->get('/cookie_component_test/set_cookie');
162+
$this->assertCookieEncrypted('abc', 'NameOfCookie', 'aes');
163+
}
143164
}

tests/test_app/TestApp/Controller/CookieComponentTestController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class CookieComponentTestController extends Controller
2727
'Cookie',
2828
];
2929

30+
public $autoRender = false;
31+
3032
/**
3133
* view
3234
*

0 commit comments

Comments
 (0)