Correct regex with non-wildcard, always check name

This commit is contained in:
j3s 2020-05-17 14:19:10 -05:00
parent 7448cd90da
commit 5b8f62a16c
1 changed files with 4 additions and 4 deletions

View File

@ -201,7 +201,7 @@ def create():
@account_required
def ssh_public_keys():
errors = list()
if request.method == "POST":
method = request.form["method"]
content = None
@ -216,7 +216,7 @@ def ssh_public_keys():
name = parts[0]
else:
errors.append("Name is required")
elif not re.match(r"^[0-9A-Za-z_@. -]+$", name):
if not re.match(r"^[0-9A-Za-z_@\. -]+$", name):
errors.append("Name must match \"^[0-9A-Za-z_@. -]+$\"")
if method == "POST":
@ -225,7 +225,7 @@ def ssh_public_keys():
errors.append("Content is required")
else:
content = content.replace("\r", "").replace("\n", "")
if not re.match(r"^(ssh|ecdsa)-[0-9A-Za-z+/_=@. -]+$", content):
if not re.match(r"^(ssh|ecdsa)-[0-9A-Za-z+/_=@\. -]+$", content):
errors.append("Content must match \"^(ssh|ecdsa)-[0-9A-Za-z+/_=@. -]+$\"")
if get_model().ssh_public_key_name_exists(session["account"], name):
@ -325,4 +325,4 @@ def account_balance():
)),
has_payments=len(payments)>0,
account_balance=format(balance_now, '.2f')
)
)