From e3248e865708f3417317ea22238489dc4f52e992 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Wed, 18 May 2022 13:53:55 -0400 Subject: [PATCH] Change cron validation to allow day abbreviations --- app/classes/web/panel_handler.py | 14 +++++--------- requirements.txt | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 5c61d3ac..a5e451ca 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -15,7 +15,7 @@ from tornado import iostream # TZLocal is set as a hidden import on win pipeline from tzlocal import get_localzone -from cron_validator import CronValidator +from croniter import croniter from app.classes.models.server_permissions import EnumPermissionsServer from app.classes.models.crafty_permissions import EnumPermissionsCrafty @@ -1447,11 +1447,9 @@ class PanelHandler(BaseHandler): else: interval_type = "" cron_string = bleach.clean(self.get_argument("cron", "")) - try: - CronValidator.parse(cron_string) - except Exception as e: + if not croniter.is_valid(cron_string): self.redirect( - f"/panel/error?error=INVALID FORMAT: Invalid Cron Format. {e}" + "/panel/error?error=INVALID FORMAT: Invalid Cron Format." ) return action = bleach.clean(self.get_argument("action", None)) @@ -1605,11 +1603,9 @@ class PanelHandler(BaseHandler): interval_type = "" cron_string = bleach.clean(self.get_argument("cron", "")) sch_id = self.get_argument("sch_id", None) - try: - CronValidator.parse(cron_string) - except Exception as e: + if not croniter.is_valid(cron_string): self.redirect( - f"/panel/error?error=INVALID FORMAT: Invalid Cron Format. {e}" + "/panel/error?error=INVALID FORMAT: Invalid Cron Format." ) return action = bleach.clean(self.get_argument("action", None)) diff --git a/requirements.txt b/requirements.txt index 26ecc613..83650349 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ argon2-cffi==20.1 bleach==4.1 cached_property==1.5.2 colorama==0.4 -cron-validator==1.0.3 +crontier==1.3.5 cryptography==3.4.8 libgravatar==1.0.0 peewee==3.13