Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit db53279

Browse filesBrowse files
committed
bug #58393 [Dotenv] Default value can be empty (HypeMC)
This PR was merged into the 5.4 branch. Discussion ---------- [Dotenv] Default value can be empty | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT According to the [spec](https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_06_02) the default value for parameter expansion can be an empty string as well, eg: ``` MY_VAR=${OTHER_VAR:-} ``` Commits ------- 17079e8 [Dotenv] Default value can be empty
2 parents 5b5f22b + 17079e8 commit db53279
Copy full SHA for db53279

File tree

Expand file treeCollapse file tree

2 files changed

+9
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-1
lines changed

‎src/Symfony/Component/Dotenv/Dotenv.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dotenv/Dotenv.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ private function resolveVariables(string $value, array $loadedVars): string
495495
(?!\() # no opening parenthesis
496496
(?P<opening_brace>\{)? # optional brace
497497
(?P<name>'.self::VARNAME_REGEX.')? # var name
498-
(?P<default_value>:[-=][^\}]++)? # optional default value
498+
(?P<default_value>:[-=][^\}]*+)? # optional default value
499499
(?P<closing_brace>\})? # optional closing brace
500500
/x';
501501

‎src/Symfony/Component/Dotenv/Tests/DotenvTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Dotenv/Tests/DotenvTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ public static function getEnvData()
175175
["FOO=BAR\nBAR=\${NOTDEFINED:=TEST}", ['FOO' => 'BAR', 'NOTDEFINED' => 'TEST', 'BAR' => 'TEST']],
176176
["FOO=\nBAR=\${FOO:=TEST}", ['FOO' => 'TEST', 'BAR' => 'TEST']],
177177
["FOO=\nBAR=\$FOO:=TEST}", ['FOO' => 'TEST', 'BAR' => 'TEST}']],
178+
["FOO=BAR\nBAR=\${FOO:-}", ['FOO' => 'BAR', 'BAR' => 'BAR']],
179+
["FOO=BAR\nBAR=\${NOTDEFINED:-}", ['FOO' => 'BAR', 'BAR' => '']],
180+
["FOO=\nBAR=\${FOO:-}", ['FOO' => '', 'BAR' => '']],
181+
["FOO=\nBAR=\$FOO:-}", ['FOO' => '', 'BAR' => '}']],
182+
["FOO=BAR\nBAR=\${FOO:=}", ['FOO' => 'BAR', 'BAR' => 'BAR']],
183+
["FOO=BAR\nBAR=\${NOTDEFINED:=}", ['FOO' => 'BAR', 'NOTDEFINED' => '', 'BAR' => '']],
184+
["FOO=\nBAR=\${FOO:=}", ['FOO' => '', 'BAR' => '']],
185+
["FOO=\nBAR=\$FOO:=}", ['FOO' => '', 'BAR' => '}']],
178186
["FOO=foo\nFOOBAR=\${FOO}\${BAR}", ['FOO' => 'foo', 'FOOBAR' => 'foo']],
179187

180188
// underscores

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.