An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: timezone settings validation
Andras Bacsaib0b81e441676
diff --git a/app/Livewire/Server/Show.php b/app/Livewire/Server/Show.phpindex bb9188f1c8..5a1743f960 100644--- a/app/Livewire/Server/Show.php+++ b/app/Livewire/Server/Show.php@@ -127,7 +127,14 @@ class Show extends Component$this->server->settings->sentinel_custom_url = $this->sentinelCustomUrl;$this->server->settings->is_sentinel_enabled = $this->isSentinelEnabled;$this->server->settings->is_sentinel_debug_enabled = $this->isSentinelDebugEnabled;- $this->server->settings->server_timezone = $this->serverTimezone;++ if (! validate_timezone($this->serverTimezone)) {+ $this->serverTimezone = config('app.timezone');+ throw new \Exception('Invalid timezone.');+ } else {+ $this->server->settings->server_timezone = $this->serverTimezone;+ }+$this->server->settings->save();} else {$this->name = $this->server->name;diff --git a/app/Livewire/Settings/Index.php b/app/Livewire/Settings/Index.phpindex 2991b8ae84..55ba49867a 100644--- a/app/Livewire/Settings/Index.php+++ b/app/Livewire/Settings/Index.php@@ -139,6 +139,14 @@ class Index extends Component$error_show = false;$this->server = Server::findOrFail(0);$this->resetErrorBag();++ if (! validate_timezone($this->instance_timezone)) {+ $this->instance_timezone = config('app.timezone');+ throw new \Exception('Invalid timezone.');+ } else {+ $this->settings->instance_timezone = $this->instance_timezone;+ }+if ($this->settings->public_port_min > $this->settings->public_port_max) {$this->addError('settings.public_port_min', 'The minimum port must be lower than the maximum port.');diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.phpindex 6e52dcde97..5e72954065 100644--- a/bootstrap/helpers/shared.php+++ b/bootstrap/helpers/shared.php@@ -385,6 +385,11 @@ function validate_cron_expression($expression_to_validate): boolreturn $isValid;}++function validate_timezone(string $timezone): bool+{+ return in_array($timezone, timezone_identifiers_list());+}function send_internal_notification(string $message): void{try {diff --git a/resources/views/livewire/server/show.blade.php b/resources/views/livewire/server/show.blade.phpindex 818412f571..dcad8ac372 100644--- a/resources/views/livewire/server/show.blade.php+++ b/resources/views/livewire/server/show.blade.php@@ -110,8 +110,7 @@wire:dirty.class.remove='dark:focus:ring-coolgray-300 dark:ring-coolgray-300'wire:dirty.class="dark:focus:ring-warning dark:ring-warning" x-model="search"@focus="open = true" @click.away="open = false" @input="open = true"- class="w-full input" :placeholder="placeholder"- wire:model.debounce.300ms="serverTimezone">+ class="w-full input" :placeholder="placeholder" wire:model="serverTimezone"><svg class="absolute right-0 mr-2 w-4 h-4" xmlns="http://www.w3.org/2000/svg"fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"@click="open = true">@@ -124,7 +123,7 @@<templatex-for="timezone in timezones.filter(tz => tz.toLowerCase().includes(search.toLowerCase()))":key="timezone">- <div @click="search = timezone; open = false; $wire.set('serverTimezone', timezone)"+ <div @click="search = timezone; open = false; $wire.set('serverTimezone', timezone); $wire.submit()"class="px-4 py-2 text-gray-800 cursor-pointer hover:bg-gray-100 dark:hover:bg-coolgray-300 dark:text-gray-200"x-text="timezone"></div></template>diff --git a/resources/views/livewire/settings/index.blade.php b/resources/views/livewire/settings/index.blade.phpindex 447c4eca50..3262139d01 100644--- a/resources/views/livewire/settings/index.blade.php+++ b/resources/views/livewire/settings/index.blade.php@@ -40,14 +40,13 @@helper="Timezone for the Coolify instance. This is used for the update check and automatic update frequency." /></div><div class="relative">- <div class="inline-flex items-center relative w-full">+ <div class="inline-flex relative items-center w-full"><input autocomplete="off"wire:dirty.class.remove='dark:focus:ring-coolgray-300 dark:ring-coolgray-300'wire:dirty.class="dark:focus:ring-warning dark:ring-warning" x-model="search"@focus="open = true" @click.away="open = false" @input="open = true"- class="w-full input " :placeholder="placeholder"- wire:model.debounce.300ms="instance_timezone">- <svg class="absolute right-0 w-4 h-4 mr-2" xmlns="http://www.w3.org/2000/svg"+ class="w-full input" :placeholder="placeholder" wire:model="instance_timezone">+ <svg class="absolute right-0 mr-2 w-4 h-4" xmlns="http://www.w3.org/2000/svg"fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"@click="open = true"><path stroke-linecap="round" stroke-linejoin="round"@@ -55,18 +54,17 @@</svg></div><div x-show="open"- class="absolute z-50 w-full mt-1 bg-white dark:bg-coolgray-100 border dark:border-coolgray-200 rounded-md shadow-lg max-h-60 overflow-auto scrollbar overflow-x-hidden">+ class="overflow-auto overflow-x-hidden absolute z-50 mt-1 w-full max-h-60 bg-white rounded-md border shadow-lg dark:bg-coolgray-100 dark:border-coolgray-200 scrollbar"><templatex-for="timezone in timezones.filter(tz => tz.toLowerCase().includes(search.toLowerCase()))":key="timezone">- <div @click="search = timezone; open = false; $wire.set('instance_timezone', timezone)"- class="px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-coolgray-300 text-gray-800 dark:text-gray-200"+ <div @click="search = timezone; open = false; $wire.set('instance_timezone', timezone); $wire.submit()"+ class="px-4 py-2 text-gray-800 cursor-pointer hover:bg-gray-100 dark:hover:bg-coolgray-300 dark:text-gray-200"x-text="timezone"></div></template></div></div></div>-</div><div class="flex gap-2 md:flex-row flex-col w-full"><x-forms.input id="public_ipv4" type="password" label="Instance's IPv4"@@ -135,7 +133,7 @@<div x-data="{ open: false }" class="mb-32 md:w-[40rem]"><button type="button" @click.prevent="open = !open"class="flex items-center justify-between w-full p-4 rounded-md- dark:bg-coolgray-100 dark:hover:bg-coolgray-200+ dark:bg-coolgray-100 dark:hover:bg-coolgray-200bg-gray-100 hover:bg-gray-200"><span class="font-medium">Two-Step Confirmation Settings</span><svg class="w-5 h-5 transition-transform" :class="{ 'rotate-180': open }" fill="none"