File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
src/Symfony/Component/DependencyInjection Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -777,7 +777,7 @@ public function compile(bool $resolveEnvPlaceholders = false)
777
777
778
778
if ($ bag instanceof EnvPlaceholderParameterBag) {
779
779
if ($ resolveEnvPlaceholders ) {
780
- $ this ->parameterBag = new ParameterBag ($ this ->resolveEnvPlaceholders ($ bag ->all (), true ));
780
+ $ this ->parameterBag = new ParameterBag ($ this ->resolveEnvPlaceholders ($ this -> escapeParameters ( $ bag ->all () ), true ));
781
781
}
782
782
783
783
$ this ->envPlaceholders = $ bag ->getEnvPlaceholders ();
@@ -1728,4 +1728,20 @@ private function inVendors(string $path): bool
1728
1728
1729
1729
return $ this ->pathsInVendor [$ path ] = false ;
1730
1730
}
1731
+
1732
+ private function escapeParameters (array $ parameters ): array
1733
+ {
1734
+ $ params = [];
1735
+ foreach ($ parameters as $ k => $ v ) {
1736
+ if (\is_array ($ v )) {
1737
+ $ params [$ k ] = $ this ->escapeParameters ($ v );
1738
+ } elseif (\is_string ($ v )) {
1739
+ $ params [$ k ] = str_replace ('% ' , '%% ' , $ v );
1740
+ } else {
1741
+ $ params [$ k ] = $ v ;
1742
+ }
1743
+ }
1744
+
1745
+ return $ params ;
1746
+ }
1731
1747
}
Original file line number Diff line number Diff line change @@ -884,6 +884,7 @@ public function testCompileWithResolveEnv()
884
884
$ container ->setParameter ('bar ' , '%% %env(DUMMY_ENV_VAR)% %env(DUMMY_SERVER_VAR)% %env(HTTP_DUMMY_VAR)% ' );
885
885
$ container ->setParameter ('foo ' , '%env(FOO)% ' );
886
886
$ container ->setParameter ('baz ' , '%foo% ' );
887
+ $ container ->setParameter ('qux ' , '%%quux%% ' );
887
888
$ container ->setParameter ('env(HTTP_DUMMY_VAR) ' , '123 ' );
888
889
$ container ->register ('teatime ' , 'stdClass ' )
889
890
->setProperty ('foo ' , '%env(DUMMY_ENV_VAR)% ' )
You can’t perform that action at this time.
0 commit comments