10000 properly parse backslashes in unquoted env vars · symfony/symfony@173fbff · GitHub
[go: up one dir, main page]

Skip to content

Commit 173fbff

Browse files
committed
properly parse backslashes in unquoted env vars
1 parent b6f9f8d commit 173fbff

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Symfony/Component/Dotenv/Dotenv.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ private function lexValue()
246246

247247
++$this->cursor;
248248
}
249-
$value = rtrim($value);
249+
$value = str_replace('\\\\', '\\', rtrim($value));
250250
$resolvedValue = $value;
251251
$resolvedValue = $this->resolveVariables($resolvedValue);
252252
$resolvedValue = $this->resolveCommands($resolvedValue);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ public function getEnvData()
6666
$_ENV['REMOTE'] = 'remote';
6767

6868
$tests = array(
69+
// backslashes
70+
array('FOO=foo\\\\bar', array('FOO' => 'foo\\bar')),
71+
array("FOO='foo\\\\bar'", array('FOO' => 'foo\\\\bar')),
72+
array('FOO="foo\\\\bar"', array('FOO' => 'foo\\bar')),
73+
6974
// spaces
7075
array('FOO=bar', array('FOO' => 'bar')),
7176
array(' FOO=bar ', array('FOO' => 'bar')),

0 commit comments

Comments
 (0)
0