bug #23342 [Dotenv] parse escaped quotes in unquoted env var values (xabbuh)
This PR was merged into the 3.3 branch.
Discussion
----------
[Dotenv] parse escaped quotes in unquoted env var values
| Q | A
| ------------- | ---
| Branch? | 3.3
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
Commits
-------
66a4fd749d
parse escaped quotes in unquoted env var values
This commit is contained in:
commit
bfd4173860
@ -215,6 +215,10 @@ final class Dotenv
|
||||
$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;
|
||||
}
|
||||
|
@ -94,6 +94,9 @@ class DotenvTest extends TestCase
|
||||
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
|
||||
|
||||
|
Reference in New Issue
Block a user