From 9e08ce7415be4f52ba1ec0ec7ef387fad0b79607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 2 Feb 2021 14:52:21 +0100 Subject: [PATCH] escape hash --- app/Http/Controllers/SetupController.php | 2 +- app/Utils/Traits/AppSetup.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index 73daf6959bf0..bc0cdc725f58 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -122,7 +122,7 @@ class SetupController extends Controller ]; try { - + foreach ($env_values as $property => $value) { $this->updateEnvironmentProperty($property, $value); } diff --git a/app/Utils/Traits/AppSetup.php b/app/Utils/Traits/AppSetup.php index 90bad966d45f..b5228f6b0961 100644 --- a/app/Utils/Traits/AppSetup.php +++ b/app/Utils/Traits/AppSetup.php @@ -118,6 +118,10 @@ trait AppSetup private function updateEnvironmentProperty(string $property, $value): void { + if (Str::contains($value, '#')) { + $value = sprintf('"%s"', $value); + } + $env = file(base_path('.env')); $position = null; @@ -135,7 +139,7 @@ trait AppSetup } elseif ($words_count > 1) { $env[$position] = "{$property}=" . '"' . $value . '"' . "\n"; // If value of variable is more than one word, surround with quotes. } 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 {