Skip to content

Commit 835f8d2

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: [VarDumper] Fix CSS alignment in HtmlDumper allow environment variables starting with an underscore Update a test [Mailer][Postmark] Add missing changelog for webhook support Remove #StandWithUkraine [Notifier][Smsc] Require login and password
2 parents f292a6a + 96d1ee8 commit 835f8d2

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Dotenv.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
final class Dotenv
2727
{
28-
public const VARNAME_REGEX = '(?i:[A-Z][A-Z0-9_]*+)';
28+
public const VARNAME_REGEX = '(?i:_?[A-Z][A-Z0-9_]*+)';
2929
public const STATE_VARNAME = 0;
3030
public const STATE_VALUE = 1;
3131

@@ -341,8 +341,8 @@ private function lexValue(): string
341341
++$this->cursor;
342342
$value = str_replace(['\\"', '\r', '\n'], ['"', "\r", "\n"], $value);
343343
$resolvedValue = $value;
344-
$resolvedValue = $this->resolveVariables($resolvedValue, $loadedVars);
345344
$resolvedValue = $this->resolveCommands($resolvedValue, $loadedVars);
345+
$resolvedValue = $this->resolveVariables($resolvedValue, $loadedVars);
346346
$resolvedValue = str_replace('\\\\', '\\', $resolvedValue);
347347
$v .= $resolvedValue;
348348
} else {
@@ -364,8 +364,8 @@ private function lexValue(): string
364364
}
365365
$value = rtrim($value);
366366
$resolvedValue = $value;
367-
$resolvedValue = $this->resolveVariables($resolvedValue, $loadedVars);
368367
$resolvedValue = $this->resolveCommands($resolvedValue, $loadedVars);
368+
$resolvedValue = $this->resolveVariables($resolvedValue, $loadedVars);
369369
$resolvedValue = str_replace('\\\\', '\\', $resolvedValue);
370370

371371
if ($resolvedValue === $value && preg_match('/\s+/', $value)) {

Tests/DotenvTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public static function getEnvDataWithFormatErrors()
5353
["FOO=\nBAR=\${FOO:-\'a{a}a}", "Unsupported character \"'\" found in the default value of variable \"\$FOO\". in \".env\" at line 2.\n...\\nBAR=\${FOO:-\'a{a}a}...\n ^ line 2 offset 24"],
5454
["FOO=\nBAR=\${FOO:-a\$a}", "Unsupported character \"\$\" found in the default value of variable \"\$FOO\". in \".env\" at line 2.\n...FOO=\\nBAR=\${FOO:-a\$a}...\n ^ line 2 offset 20"],
5555
["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"],
56+
['_=FOO', "Invalid character in variable name in \".env\" at line 1.\n..._=FOO...\n ^ line 1 offset 0"],
5657
];
5758

5859
if ('\\' !== \DIRECTORY_SEPARATOR) {
@@ -175,6 +176,10 @@ public static function getEnvData()
175176
["FOO=\nBAR=\${FOO:=TEST}", ['FOO' => 'TEST', 'BAR' => 'TEST']],
176177
["FOO=\nBAR=\$FOO:=TEST}", ['FOO' => 'TEST', 'BAR' => 'TEST}']],
177178
["FOO=foo\nFOOBAR=\${FOO}\${BAR}", ['FOO' => 'foo', 'FOOBAR' => 'foo']],
179+
180+
// underscores
181+
['_FOO=BAR', ['_FOO' => 'BAR']],
182+
['_FOO_BAR=FOOBAR', ['_FOO_BAR' => 'FOOBAR']],
178183
];
179184

180185
if ('\\' !== \DIRECTORY_SEPARATOR) {

0 commit comments

Comments
 (0)