Fix crash on invalid username in forums import

This commit is contained in:
rubenwardy
2022-01-21 21:20:04 +00:00
parent fe2d08c395
commit 80d534a53f
4 changed files with 18 additions and 10 deletions

View File

@@ -19,11 +19,16 @@ import secrets
from .flask import *
from .models import *
from .user import *
import re
YESES = ["yes", "true", "1", "on"]
def is_username_valid(username):
return username is not None and len(username) >= 2 and re.match(r"^[A-Za-z0-9._-]*$", username)
def isYes(val):
return val and val.lower() in YESES