From 01b9cbdfeae877bc0e4be5957f51aad9768b2f36 Mon Sep 17 00:00:00 2001 From: Efthymis Sarmpanis Date: Mon, 27 Jan 2025 22:50:54 +0200 Subject: [PATCH] fix: validate cron expression in Scheduled Task update --- app/Livewire/Project/Shared/ScheduledTask/Show.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Livewire/Project/Shared/ScheduledTask/Show.php b/app/Livewire/Project/Shared/ScheduledTask/Show.php index 0764ab3b9..947eeb5af 100644 --- a/app/Livewire/Project/Shared/ScheduledTask/Show.php +++ b/app/Livewire/Project/Shared/ScheduledTask/Show.php @@ -77,6 +77,10 @@ class Show extends Component { if ($toModel) { $this->validate(); + $isValid = validate_cron_expression($this->frequency); + if (! $isValid) { + throw new \Exception('Invalid Cron / Human expression.'); + } $this->task->enabled = $this->isEnabled; $this->task->name = str($this->name)->trim()->value(); $this->task->command = str($this->command)->trim()->value(); @@ -109,7 +113,7 @@ class Show extends Component $this->syncData(true); $this->dispatch('success', 'Scheduled task updated.'); } catch (\Exception $e) { - return handleError($e); + return handleError($e, $this); } }