diff --git a/src/Configurator/EnvConfigurator.php b/src/Configurator/EnvConfigurator.php index 339df943..01a5abe3 100644 --- a/src/Configurator/EnvConfigurator.php +++ b/src/Configurator/EnvConfigurator.php @@ -93,7 +93,7 @@ private function configureEnvDist(Recipe $recipe, $vars, bool $update) } $value = $this->options->expandTargetDir($value); - if (false !== strpbrk($value, " \t\n&!\"")) { + if (!str_starts_with($value, "'") && !str_ends_with($value, "'") && false !== strpbrk($value, " \t\n&!\"")) { $value = '"'.str_replace(['\\', '"', "\t", "\n"], ['\\\\', '\\"', '\t', '\n'], $value).'"'; } $data .= "$key=$value\n"; diff --git a/tests/Configurator/DotenvConfiguratorTest.php b/tests/Configurator/DotenvConfiguratorTest.php index e8d794bf..148a0f81 100644 --- a/tests/Configurator/DotenvConfiguratorTest.php +++ b/tests/Configurator/DotenvConfiguratorTest.php @@ -51,6 +51,7 @@ public function testConfigure() '#2' => 'Comment 3', '#TRUSTED_SECRET' => 's3cretf0rt3st"<>', 'APP_SECRET' => 's3cretf0rt3st"<>', + 'ALLOWED_LANGUAGES' => '\'["en","de","es"]\'', ], ], $lock); @@ -67,6 +68,7 @@ public function testConfigure() # Comment 3 #TRUSTED_SECRET="s3cretf0rt3st\"<>" APP_SECRET="s3cretf0rt3st\"<>" +ALLOWED_LANGUAGES='["en","de","es"]' ###< FooBundle ### EOF; diff --git a/tests/Configurator/EnvConfiguratorTest.php b/tests/Configurator/EnvConfiguratorTest.php index 1d7e237f..c5f71c3d 100644 --- a/tests/Configurator/EnvConfiguratorTest.php +++ b/tests/Configurator/EnvConfiguratorTest.php @@ -56,6 +56,7 @@ public function testConfigure() '#2' => 'Comment 3', '#TRUSTED_SECRET' => 's3cretf0rt3st"<>', 'APP_SECRET' => 's3cretf0rt3st"<>', + 'ALLOWED_LANGUAGES' => '\'["en","de","es"]\'', ], $lock); $envContents = <<" APP_SECRET="s3cretf0rt3st\"<>" +ALLOWED_LANGUAGES='["en","de","es"]' ###< FooBundle ### EOF; @@ -99,6 +101,7 @@ public function testConfigure() +