diff --git a/src/Core/Config/Util/ConfigFileTransformer.php b/src/Core/Config/Util/ConfigFileTransformer.php index 9b80991af..282714df2 100644 --- a/src/Core/Config/Util/ConfigFileTransformer.php +++ b/src/Core/Config/Util/ConfigFileTransformer.php @@ -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; diff --git a/tests/datasets/config/B.node.config.php b/tests/datasets/config/B.node.config.php index 94b2e3f12..499e092a4 100644 --- a/tests/datasets/config/B.node.config.php +++ b/tests/datasets/config/B.node.config.php @@ -34,5 +34,6 @@ return [ 'theme' => 'frio', 'int' => 23, 'float' => 2.5, + 'with special chars' => 'I can\'t follow this "$&§%"$%§$%&\'[),', ], ]; diff --git a/tests/src/Core/Config/Cache/ConfigFileLoaderTest.php b/tests/src/Core/Config/Cache/ConfigFileManagerTest.php similarity index 98% rename from tests/src/Core/Config/Cache/ConfigFileLoaderTest.php rename to tests/src/Core/Config/Cache/ConfigFileManagerTest.php index aed55f429..99049426b 100644 --- a/tests/src/Core/Config/Cache/ConfigFileLoaderTest.php +++ b/tests/src/Core/Config/Cache/ConfigFileManagerTest.php @@ -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 = '!"§$%&/()(/&%$\'>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)); } }