forked from 3wordchant/capsul-flask
Correct regex with non-wildcard, always check name
This commit is contained in:
parent
7448cd90da
commit
5b8f62a16c
@ -201,7 +201,7 @@ def create():
|
|||||||
@account_required
|
@account_required
|
||||||
def ssh_public_keys():
|
def ssh_public_keys():
|
||||||
errors = list()
|
errors = list()
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
method = request.form["method"]
|
method = request.form["method"]
|
||||||
content = None
|
content = None
|
||||||
@ -216,7 +216,7 @@ def ssh_public_keys():
|
|||||||
name = parts[0]
|
name = parts[0]
|
||||||
else:
|
else:
|
||||||
errors.append("Name is required")
|
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_@. -]+$\"")
|
errors.append("Name must match \"^[0-9A-Za-z_@. -]+$\"")
|
||||||
|
|
||||||
if method == "POST":
|
if method == "POST":
|
||||||
@ -225,7 +225,7 @@ def ssh_public_keys():
|
|||||||
errors.append("Content is required")
|
errors.append("Content is required")
|
||||||
else:
|
else:
|
||||||
content = content.replace("\r", "").replace("\n", "")
|
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+/_=@. -]+$\"")
|
errors.append("Content must match \"^(ssh|ecdsa)-[0-9A-Za-z+/_=@. -]+$\"")
|
||||||
|
|
||||||
if get_model().ssh_public_key_name_exists(session["account"], name):
|
if get_model().ssh_public_key_name_exists(session["account"], name):
|
||||||
@ -325,4 +325,4 @@ def account_balance():
|
|||||||
)),
|
)),
|
||||||
has_payments=len(payments)>0,
|
has_payments=len(payments)>0,
|
||||||
account_balance=format(balance_now, '.2f')
|
account_balance=format(balance_now, '.2f')
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user