mirror of
https://github.com/friendica/friendica
synced 2024-11-09 16:22:56 +00:00
Escape single quotes and backslashes
This commit is contained in:
parent
65d79d4c93
commit
dd88d193b9
3 changed files with 10 additions and 3 deletions
|
@ -75,7 +75,7 @@ class ConfigFileTransformer
|
|||
} elseif (is_numeric($value)) {
|
||||
$string .= $value . ",";
|
||||
} else {
|
||||
$string .= sprintf('\'%s\',', $value);
|
||||
$string .= sprintf('\'%s\',', addcslashes($value, '\'\\'));
|
||||
}
|
||||
|
||||
$string .= PHP_EOL;
|
||||
|
|
|
@ -34,5 +34,6 @@ return [
|
|||
'theme' => 'frio',
|
||||
'int' => 23,
|
||||
'float' => 2.5,
|
||||
'with special chars' => 'I can\'t follow this "$&§%"$%§$%&\'[),',
|
||||
],
|
||||
];
|
||||
|
|
|
@ -28,7 +28,7 @@ use Friendica\Test\Util\VFSTrait;
|
|||
use Friendica\Core\Config\Util\ConfigFileManager;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
|
||||
class ConfigFileLoaderTest extends MockedTest
|
||||
class ConfigFileManagerTest extends MockedTest
|
||||
{
|
||||
use VFSTrait;
|
||||
|
||||
|
@ -407,10 +407,13 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
|
||||
$configFileLoader->setupCache($configCache);
|
||||
|
||||
$specialChars = '!"§$%&/()(/&%$\'><?$a,;:[]}{}\\';
|
||||
|
||||
// overwrite some data and save it back to the config file
|
||||
$configCache->set('system', 'test', 'it', Cache::SOURCE_DATA);
|
||||
$configCache->set('config', 'test', 'it', Cache::SOURCE_DATA);
|
||||
$configCache->set('system', 'test_2', 2, Cache::SOURCE_DATA);
|
||||
$configCache->set('special_chars', 'special', $specialChars, Cache::SOURCE_DATA);
|
||||
$configFileLoader->saveData($configCache);
|
||||
|
||||
// Reload the configCache with the new values
|
||||
|
@ -424,7 +427,10 @@ class ConfigFileLoaderTest extends MockedTest
|
|||
'test_2' => 2
|
||||
],
|
||||
'config' => [
|
||||
'test' => 'it'
|
||||
'test' => 'it',
|
||||
],
|
||||
'special_chars' => [
|
||||
'special' => $specialChars,
|
||||
]], $configCache2->getDataBySource(Cache::SOURCE_DATA));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue