From 96921c2a29d561bc0895432f2316c3c9139c7c0c Mon Sep 17 00:00:00 2001 From: yackob03 Date: Fri, 15 Nov 2013 12:31:39 -0500 Subject: [PATCH] Update the username validation to match the Docker CLI rules. --- util/validation.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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):