[2.0.x] Fixed #29176 -- Fixed AbstractBaseUser.normalize_username() crash if username isn't a string.
Backport of 40bac28faabbacd0875e59455cd80fb1dbb16966 from master
This commit is contained in:
parent
3cdc88ba53
commit
e91ff6e29c
@ -138,4 +138,4 @@ class AbstractBaseUser(models.Model):
|
||||
|
||||
@classmethod
|
||||
def normalize_username(cls, username):
|
||||
return unicodedata.normalize('NFKC', username) if username else username
|
||||
return unicodedata.normalize('NFKC', username) if isinstance(username, str) else username
|
||||
|
@ -28,3 +28,6 @@ Bugfixes
|
||||
|
||||
* Fixed crash when using a ``Window()`` expression in a subquery
|
||||
(:ticket:`29172`).
|
||||
|
||||
* Fixed ``AbstractBaseUser.normalize_username()`` crash if the ``username``
|
||||
argument isn't a string (:ticket:`29176`).
|
||||
|
@ -12,6 +12,7 @@ from django.core import mail
|
||||
from django.db.models.signals import post_save
|
||||
from django.test import TestCase, override_settings
|
||||
|
||||
from .models import IntegerUsernameUser
|
||||
from .models.with_custom_email_field import CustomEmailField
|
||||
|
||||
|
||||
@ -157,6 +158,9 @@ class UserManagerTestCase(TestCase):
|
||||
|
||||
class AbstractBaseUserTests(TestCase):
|
||||
|
||||
def test_normalize_username(self):
|
||||
self.assertEqual(IntegerUsernameUser().normalize_username(123), 123)
|
||||
|
||||
def test_clean_normalize_username(self):
|
||||
# The normalization happens in AbstractBaseUser.clean()
|
||||
ohm_username = 'iamtheΩ' # U+2126 OHM SIGN
|
||||
|
Loading…
x
Reference in New Issue
Block a user