File tree Expand file tree Collapse file tree 3 files changed +9
-1
lines changed
src/Symfony/Component/Dotenv Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Original file line number Diff line number Diff line change
1
+ FOOBAR = ${ BAR:=production }
Original file line number Diff line number Diff line change @@ -427,7 +427,7 @@ private function resolveVariables($value)
427
427
(?!\() # no opening parenthesis
428
428
(?P<opening_brace>\{)? # optional brace
429
429
(?P<name> ' .self ::VARNAME_REGEX .')? # var name
430
- (?P<default_value>(?:(:-)( [^\}]+)))? # optional default value
430
+ (?P<default_value>:- [^\}]+)? # optional default value
431
431
(?P<closing_brace>\})? # optional closing brace
432
432
/x ' ;
433
433
@@ -458,6 +458,10 @@ private function resolveVariables($value)
458
458
}
459
459
460
460
if ('' === $ value && isset ($ matches ['default_value ' ])) {
461
+ if (strpbrk ($ matches ['default_value ' ], '\'"{}$ ' )) {
462
+ throw $ this ->createFormatException ('Invalid character in default value ' );
463
+ }
464
+
461
465
$ value = substr ($ matches ['default_value ' ], 2 );
462
466
}
463
467
Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ public function getEnvDataWithFormatErrors()
48
48
['FOO! ' , "Missing = in the environment variable declaration in \".env \" at line 1. \n...FOO!... \n ^ line 1 offset 3 " ],
49
49
['FOO=$(echo foo ' , "Missing closing parenthesis. in \".env \" at line 1. \n...FOO=$(echo foo... \n ^ line 1 offset 14 " ],
50
50
['FOO=$(echo foo ' ."\n" , "Missing closing parenthesis. in \".env \" at line 1. \n...FOO=$(echo foo \\n... \n ^ line 1 offset 14 " ],
51
+ ["FOO= \nBAR= \${FOO:-\'a{a}a} " , "Invalid character in default value in \".env \" at line 2. \n... \\nBAR= \${FOO:-\'a{a}a}... \n ^ line 2 offset 24 " ],
52
+ ["FOO= \nBAR= \${FOO:-a \$a} " , "Invalid character in default value in \".env \" at line 2. \n...FOO= \\nBAR= \${FOO:-a \$a}... \n ^ line 2 offset 20 " ],
53
+ ["FOO= \nBAR= \${FOO:-a \"a} " , "Unclosed braces on variable expansion in \".env \" at line 2. \n...FOO= \\nBAR= \${FOO:-a \"a}... \n ^ line 2 offset 17 " ],
51
54
];
52
55
53
56
if ('\\' !== \DIRECTORY_SEPARATOR ) {
You can’t perform that action at this time.
0 commit comments