mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #4818 from beganovich/v5-0202-wrap-env-in-quotes
(v5) Escape # from .env values
This commit is contained in:
commit
52980c5f94
@ -122,7 +122,7 @@ class SetupController extends Controller
|
|||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
foreach ($env_values as $property => $value) {
|
foreach ($env_values as $property => $value) {
|
||||||
$this->updateEnvironmentProperty($property, $value);
|
$this->updateEnvironmentProperty($property, $value);
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,10 @@ trait AppSetup
|
|||||||
|
|
||||||
private function updateEnvironmentProperty(string $property, $value): void
|
private function updateEnvironmentProperty(string $property, $value): void
|
||||||
{
|
{
|
||||||
|
if (Str::contains($value, '#')) {
|
||||||
|
$value = sprintf('"%s"', $value);
|
||||||
|
}
|
||||||
|
|
||||||
$env = file(base_path('.env'));
|
$env = file(base_path('.env'));
|
||||||
|
|
||||||
$position = null;
|
$position = null;
|
||||||
@ -135,7 +139,7 @@ trait AppSetup
|
|||||||
} elseif ($words_count > 1) {
|
} elseif ($words_count > 1) {
|
||||||
$env[$position] = "{$property}=" . '"' . $value . '"' . "\n"; // If value of variable is more than one word, surround with quotes.
|
$env[$position] = "{$property}=" . '"' . $value . '"' . "\n"; // If value of variable is more than one word, surround with quotes.
|
||||||
} else {
|
} else {
|
||||||
$env[$position] = "{$property}=" . $value . "\n"; // Just a normal variable update, with prexisting keys.
|
$env[$position] = "{$property}=" . $value . "\n"; // Just a normal variable update, with pre-existing keys.
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user