better cron validation

This commit is contained in:
Andrew 2022-01-14 12:59:33 -05:00
parent 630eb27c50
commit 8723a44402
2 changed files with 4 additions and 3 deletions

View File

@ -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

View File

@ -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":