mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Updating Configure::store to fix escaping issues
Signed-off-by: Mark Story <mark@mark-story.com>
This commit is contained in:
parent
06d4e5e553
commit
862ff82ad4
2 changed files with 6 additions and 16 deletions
|
@ -459,20 +459,7 @@ class Configure extends Object {
|
||||||
$content = '';
|
$content = '';
|
||||||
|
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
$content .= "\$config['$type']['$key']";
|
$content .= "\$config['$type']['$key'] = " . var_export($value, true) . ";\n";
|
||||||
|
|
||||||
if (is_array($value)) {
|
|
||||||
$content .= " = array(";
|
|
||||||
|
|
||||||
foreach ($value as $key1 => $value2) {
|
|
||||||
$value2 = addslashes($value2);
|
|
||||||
$content .= "'$key1' => '$value2', ";
|
|
||||||
}
|
|
||||||
$content .= ");\n";
|
|
||||||
} else {
|
|
||||||
$value = addslashes($value);
|
|
||||||
$content .= " = '$value';\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (is_null($type)) {
|
if (is_null($type)) {
|
||||||
$write = false;
|
$write = false;
|
||||||
|
|
|
@ -224,14 +224,17 @@ class ConfigureTest extends CakeTestCase {
|
||||||
function testStoreAndLoad() {
|
function testStoreAndLoad() {
|
||||||
Configure::write('Cache.disable', false);
|
Configure::write('Cache.disable', false);
|
||||||
|
|
||||||
$expected = array('data' => 'value');
|
$expected = array('data' => 'value with backslash \, \'singlequote\' and "doublequotes"');
|
||||||
Configure::store('SomeExample', 'test', $expected);
|
Configure::store('SomeExample', 'test', $expected);
|
||||||
|
|
||||||
Configure::load('test');
|
Configure::load('test');
|
||||||
$config = Configure::read('SomeExample');
|
$config = Configure::read('SomeExample');
|
||||||
$this->assertEqual($config, $expected);
|
$this->assertEqual($config, $expected);
|
||||||
|
|
||||||
$expected = array('data' => array('first' => 'value', 'second' => 'value2'));
|
$expected = array(
|
||||||
|
'data' => array('first' => 'value with backslash \, \'singlequote\' and "doublequotes"', 'second' => 'value2'),
|
||||||
|
'data2' => 'value'
|
||||||
|
);
|
||||||
Configure::store('AnotherExample', 'test.config', $expected);
|
Configure::store('AnotherExample', 'test.config', $expected);
|
||||||
|
|
||||||
Configure::load('test.config');
|
Configure::load('test.config');
|
||||||
|
|
Loading…
Reference in a new issue