Based on the issue description, I need to generate a patch for Django's `contrib/auth/validators.py` file. The issue is that the username validators use `^` and `$` anchors which allow trailing newlines. The fix is to use `\A` and `\Z` instead. Here's the patch: --- a/django/contrib/auth/validators.py +++ b/django/contrib/auth/validators.py @@ -7,7 +7,7 @@ from django.utils.translation import gettext_lazy as _ @deconstructible class ASCIIUsernameValidator(validators.RegexValidator): - regex = r'^[\w.@+-]+$' + regex = r'\A[\w.@+-]+\Z' message = _( 'Enter a valid username. This value may contain only English letters, ' 'numbers, and @/./+/-/_ characters.' @@ -17,7 +17,7 @@ class ASCIIUsernameValidator(validators.RegexValidator): @deconstructible class UnicodeUsernameValidator(validators.RegexValidator): - regex = r'^[\w.@+-]+$' + regex = r'\A[\w.@+-]+\Z' message = _( 'Enter a valid username. This value may contain only letters, ' 'numbers, and @/./+/-/_ characters.'