From f1f6dea04ff51714f0742c4aa601220d62093142 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Wed, 14 Aug 2024 21:54:46 +0200 Subject: [PATCH] updated cron validation for the case of null, return false --- bootstrap/helpers/shared.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index aae4fafd4..6e0f6dd35 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -355,9 +355,17 @@ function isCloud(): bool function validate_cron_expression($expression_to_validate): bool { + if ($expression_to_validate === null || $expression_to_validate === '') { + return false; + } + $isValid = false; - $expression = new CronExpression($expression_to_validate); - $isValid = $expression->isValid(); + try { + $expression = new CronExpression($expression_to_validate); + $isValid = $expression->isValid(); + } catch (\Exception $e) { + return false; + } if (isset(VALID_CRON_STRINGS[$expression_to_validate])) { $isValid = true;