Fix next line read with double quote blocks in one line
If there was this FOO="bar" Then the # comment block was attached to bar because FOO was seen as a multiline block although the quotes are in one line only
This commit is contained in:
@@ -49,11 +49,12 @@ function readEnvFile(string $path = __DIR__, string $env_file = '.env'): int
|
|||||||
// wirte only if env is not set yet, and write only the first time
|
// wirte only if env is not set yet, and write only the first time
|
||||||
if (empty($_ENV[$var])) {
|
if (empty($_ENV[$var])) {
|
||||||
if (!empty($quotes)) {
|
if (!empty($quotes)) {
|
||||||
$block = true;
|
|
||||||
// match greedy for first to last so we move any " if there are
|
// match greedy for first to last so we move any " if there are
|
||||||
if (preg_match('/^"(.*[^\\\])"/U', $value, $matches)) {
|
if (preg_match('/^"(.*[^\\\])"/U', $value, $matches)) {
|
||||||
$value = $matches[1];
|
$value = $matches[1];
|
||||||
} else {
|
} else {
|
||||||
|
// this is a multi line
|
||||||
|
$block = true;
|
||||||
// first " in string remove
|
// first " in string remove
|
||||||
// add removed new line back because this is a multi line
|
// add removed new line back because this is a multi line
|
||||||
$value = ltrim($value, '"') . PHP_EOL;
|
$value = ltrim($value, '"') . PHP_EOL;
|
||||||
|
|||||||
Reference in New Issue
Block a user