Do not allow decimal points in quota sizes

This commit is contained in:
John Supplee 2019-02-05 01:47:39 +02:00
parent 686a074fab
commit a60e1c274a
1 changed files with 9 additions and 9 deletions

View File

@ -428,17 +428,17 @@ def get_default_quota(env):
return config.get("default-quota", '0') return config.get("default-quota", '0')
def validate_quota(quota): def validate_quota(quota):
# validate quota # validate quota
quota = quota.strip().upper() quota = quota.strip().upper()
if quota == "": if quota == "":
raise ValueError("No quota provided.") raise ValueError("No quota provided.")
if re.search(r"[\s,]", quota): if re.search(r"[\s,.]", quota):
raise ValueError("Quotas cannot contain spaces or commas.") raise ValueError("Quotas cannot contain spaces, commas, or decimal points.")
if not re.match(r'^[\d\.]+[GM]?$', quota): if not re.match(r'^[\d]+[GM]?$', quota):
raise ValueError("Invalid quota.") raise ValueError("Invalid quota.")
return quota return quota
def get_mail_password(email, env): def get_mail_password(email, env):
# Gets the hashed password for a user. Passwords are stored in Dovecot's # Gets the hashed password for a user. Passwords are stored in Dovecot's