File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,10 @@ class UsernameMixin:
158158
159159 def clean_username (self ):
160160 name = self .cleaned_data ['username' ]
161+ # All-digits usernames are disallowed since they can be
162+ # confused for user IDs in URLs. (See bug 862121.)
163+ if name .isdigit ():
164+ raise forms .ValidationError (_ ('Usernames cannot contain only digits.' ))
161165 slug_validator (name , lower = False ,
162166 message = _ ('Enter a valid username consisting of letters, numbers, '
163167 'underscores or hyphens.' ))
Original file line number Diff line number Diff line change @@ -437,6 +437,15 @@ def test_blacklisted_username(self):
437437 self .assertFormError (r , 'form' , 'username' ,
438438 'This username cannot be used.' )
439439
440+ def test_alldigit_username (self ):
441+ data = {'email' : 'testo@example.com' ,
442+ 'password' : 'xxxlonger' ,
443+ 'password2' : 'xxxlonger' ,
444+ 'username' : '8675309' , }
445+ r = self .client .post ('/en-US/firefox/users/register' , data )
446+ self .assertFormError (r , 'form' , 'username' ,
447+ 'Usernames cannot contain only digits.' )
448+
440449 def test_blacklisted_password (self ):
441450 BlacklistedPassword .objects .create (password = 'password' )
442451 data = {'email' : 'testo@example.com' ,
You can’t perform that action at this time.
0 commit comments