bug #23434 [DotEnv] Fix variable substitution (brieucthomas)
This PR was merged into the 3.3 branch.
Discussion
----------
[DotEnv] Fix variable substitution
| Q | A
| ------------- | ---
| Branch? | 3.3
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #23423
| License | MIT
| Doc PR | no
Commits
-------
1dfcdc7000
[DotEnv] Fix variable substitution
This commit is contained in:
commit
c3ec5c5361
@ -351,7 +351,7 @@ final class Dotenv
|
|||||||
}
|
}
|
||||||
|
|
||||||
$name = $matches[3];
|
$name = $matches[3];
|
||||||
$value = isset($this->values[$name]) ? $this->values[$name] : (isset($_ENV[$name]) ? isset($_ENV[$name]) : (string) getenv($name));
|
$value = isset($this->values[$name]) ? $this->values[$name] : (isset($_ENV[$name]) ? $_ENV[$name] : (string) getenv($name));
|
||||||
|
|
||||||
if (!$matches[2] && isset($matches[4])) {
|
if (!$matches[2] && isset($matches[4])) {
|
||||||
$value .= '}';
|
$value .= '}';
|
||||||
|
@ -63,6 +63,7 @@ class DotenvTest extends TestCase
|
|||||||
public function getEnvData()
|
public function getEnvData()
|
||||||
{
|
{
|
||||||
putenv('LOCAL=local');
|
putenv('LOCAL=local');
|
||||||
|
$_ENV['REMOTE'] = 'remote';
|
||||||
|
|
||||||
$tests = array(
|
$tests = array(
|
||||||
// spaces
|
// spaces
|
||||||
@ -134,6 +135,7 @@ class DotenvTest extends TestCase
|
|||||||
array('FOO=" \\$ "', array('FOO' => ' $ ')),
|
array('FOO=" \\$ "', array('FOO' => ' $ ')),
|
||||||
array('FOO=" $ "', array('FOO' => ' $ ')),
|
array('FOO=" $ "', array('FOO' => ' $ ')),
|
||||||
array('BAR=$LOCAL', array('BAR' => 'local')),
|
array('BAR=$LOCAL', array('BAR' => 'local')),
|
||||||
|
array('BAR=$REMOTE', array('BAR' => 'remote')),
|
||||||
array('FOO=$NOTDEFINED', array('FOO' => '')),
|
array('FOO=$NOTDEFINED', array('FOO' => '')),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user