mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
fix CookieComponent - when write null or empty string
This commit is contained in:
parent
e61ac62bfa
commit
11f543f1f2
2 changed files with 31 additions and 1 deletions
|
@ -472,7 +472,7 @@ class CookieComponent extends Component {
|
|||
if (is_array($value)) {
|
||||
$value = $this->_implode($value);
|
||||
}
|
||||
if (!$this->_encrypted) {
|
||||
if (!$this->_encrypted || !$value) {
|
||||
return $value;
|
||||
}
|
||||
$prefix = "Q2FrZQ==.";
|
||||
|
|
|
@ -201,6 +201,36 @@ class CookieComponentTest extends CakeTestCase {
|
|||
$this->assertEquals('value', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test write() Encrypted data with null & empty string & boolean value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testWriteWithNullEmptyString() {
|
||||
$this->Cookie->type('aes');
|
||||
$this->Cookie->key = 'qSI232qs*&sXOw!adre@34SAv!@*(XSL#$%)asGb$@11~_+!@#HKis~#^';
|
||||
|
||||
$this->Cookie->write('Testing');
|
||||
$result = $this->Cookie->read('Testing');
|
||||
$this->assertNull($result);
|
||||
|
||||
$this->Cookie->write('Testing', '');
|
||||
$result = $this->Cookie->read('Testing');
|
||||
$this->assertEquals('', $result);
|
||||
|
||||
$this->Cookie->write('Testing', false);
|
||||
$result = $this->Cookie->read('Testing');
|
||||
$this->assertFalse($result);
|
||||
|
||||
$this->Cookie->write('Testing', 1);
|
||||
$result = $this->Cookie->read('Testing');
|
||||
$this->assertEquals(1, $result);
|
||||
|
||||
$this->Cookie->write('Testing', '0');
|
||||
$result = $this->Cookie->read('Testing');
|
||||
$this->assertEquals('0', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that two write() calls use the expiry.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue