Permalink
Browse files

Adding an array cast to fix issues where users could modify cookie

values causing iteration errors.  Fixes #1309
  • Loading branch information...
1 parent b567de9 commit 0e29567f8d8110948140b6445be4812750181ba8 @markstory markstory committed Nov 25, 2010
@@ -411,7 +411,7 @@ function __decrypt($values) {
$decrypted = array();
$type = $this->__type;
- foreach ($values as $name => $value) {
+ foreach ((array)$values as $name => $value) {
if (is_array($value)) {
foreach ($value as $key => $val) {
$pos = strpos($val, 'Q2FrZQ==.');
@@ -437,6 +437,19 @@ function testReadingCookieDataWithoutStartup() {
unset($_COOKIE['CakeTestCookie']);
}
+
+/**
+ * test that no error is issued for non array data.
+ *
+ * @return void
+ */
+ function testNoErrorOnNonArrayData() {
+ $this->Controller->Cookie->destroy();
+ $_COOKIE['CakeTestCookie'] = 'kaboom';
+
+ $this->assertNull($this->Controller->Cookie->read('value'));
+ }
+
/**
* encrypt method
*

0 comments on commit 0e29567

Please sign in to comment.