diff --git a/src/Symfony/Component/Dotenv/Dotenv.php b/src/Symfony/Component/Dotenv/Dotenv.php index 1e665fb537a7..3f8623437a47 100644 --- a/src/Symfony/Component/Dotenv/Dotenv.php +++ b/src/Symfony/Component/Dotenv/Dotenv.php @@ -215,6 +215,10 @@ private function lexValue() $notQuoted = true; $prevChr = $this->data[$this->cursor - 1]; while ($this->cursor < $this->end && "\n" !== $this->data[$this->cursor] && !((' ' === $prevChr || "\t" === $prevChr) && '#' === $this->data[$this->cursor])) { + if ('\\' === $this->data[$this->cursor] && isset($this->data[$this->cursor + 1]) && ('"' === $this->data[$this->cursor + 1] || "'" === $this->data[$this->cursor + 1])) { + ++$this->cursor; + } + $value .= $prevChr = $this->data[$this->cursor]; ++$this->cursor; } diff --git a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php index 62aa94295e9b..c257b84f0f01 100644 --- a/src/Symfony/Component/Dotenv/Tests/DotenvTest.php +++ b/src/Symfony/Component/Dotenv/Tests/DotenvTest.php @@ -94,6 +94,9 @@ public function getEnvData() array('FOO=" "', array('FOO' => ' ')), array('PATH="c:\\\\"', array('PATH' => 'c:\\')), array("FOO=\"bar\nfoo\"", array('FOO' => "bar\nfoo")), + array('FOO=BAR\\"', array('FOO' => 'BAR"')), + array("FOO=BAR\\'BAZ", array('FOO' => "BAR'BAZ")), + array('FOO=\\"BAR', array('FOO' => '"BAR')), // concatenated values