diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-10-17 11:48:32 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-11-01 06:26:16 +0100 |
| commit | 4965bfdde2e5a5c883685019e57d123a3368a75e (patch) | |
| tree | 5a513d89b582104dcbcb8513c1abf62009ff993e /tests/auth_tests/test_forms.py | |
| parent | 8581d916899ccd4fe4c09742c9b2b2d2bf3cc457 (diff) | |
[4.1.x] Fixed CVE-2023-46695 -- Fixed potential DoS in UsernameField on Windows.
Thanks MProgrammer (https://hackerone.com/mprogrammer) for the report.
Diffstat (limited to 'tests/auth_tests/test_forms.py')
| -rw-r--r-- | tests/auth_tests/test_forms.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py index ea52254123..f3938d0275 100644 --- a/tests/auth_tests/test_forms.py +++ b/tests/auth_tests/test_forms.py @@ -12,6 +12,7 @@ from django.contrib.auth.forms import ( SetPasswordForm, UserChangeForm, UserCreationForm, + UsernameField, ) from django.contrib.auth.models import User from django.contrib.auth.signals import user_login_failed @@ -150,6 +151,12 @@ class UserCreationFormTest(TestDataMixin, TestCase): self.assertNotEqual(user.username, ohm_username) self.assertEqual(user.username, "testΩ") # U+03A9 GREEK CAPITAL LETTER OMEGA + def test_invalid_username_no_normalize(self): + field = UsernameField(max_length=254) + # Usernames are not normalized if they are too long. + self.assertEqual(field.to_python("½" * 255), "½" * 255) + self.assertEqual(field.to_python("ff" * 254), "ff" * 254) + def test_duplicate_normalized_unicode(self): """ To prevent almost identical usernames, visually identical but differing |
