From 8723a444029baf734f2c2a103aa10fa9826acb1e Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 14 Jan 2022 12:59:33 -0500 Subject: [PATCH] better cron validation --- app/classes/shared/main_controller.py | 1 - app/classes/web/panel_handler.py | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index 1fa675a0..8e1615aa 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -6,7 +6,6 @@ import sys from app.classes.models.server_permissions import Enum_Permissions_Server from app.classes.models.users import helper_users from peewee import DoesNotExist -import schedule import yaml import asyncio import shutil diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index f84493d0..9a90836f 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -1112,8 +1112,10 @@ class PanelHandler(BaseHandler): interval_type = '' cron_string = bleach.clean(self.get_argument('cron', '')) sch_id = self.get_argument('sch_id', None) - if len(cron_string.split(' ')) != 5: - self.redirect("/panel/error?error=INVALID FORMAT: Invalid Cron Format. Cron must have a space between each character and only have a max of 5 characters * * * * *") + try: + CronValidator.parse(cron_string) + except Exception as e: + self.redirect("/panel/error?error=INVALID FORMAT: Invalid Cron Format. {}".format(e)) return action = bleach.clean(self.get_argument('action', None)) if action == "command":