diff --git a/util/validation.py b/util/validation.py index bbe02e017..895767d98 100644 --- a/util/validation.py +++ b/util/validation.py @@ -1,5 +1,4 @@ import re -import urllib INVALID_PASSWORD_MESSAGE = 'Invalid password, password must be at least ' + \ '8 characters and contain no whitespace.' @@ -12,9 +11,9 @@ def validate_email(email_address): def validate_username(username): # Minimum length of 2, maximum length of 255, no url unsafe characters - return (urllib.quote(username, safe='') == username and - len(username) > 1 and - len(username) < 256) + return (re.search(r'[^a-z0-9_]', username) is None and + len(username) >= 4 and + len(username) <= 30) def validate_password(password):