mirror of
https://github.com/django/django.git
synced 2025-03-14 03:10:45 +00:00
[1.9.x] Refs #16860 -- Fixed password help text when there aren't any validators.
This avoids creating an empty list which is invalid HTML 4. Backport of 53ccffdb8c8e47a4d4304df453d8c79a9be295ab from master
This commit is contained in:
parent
0094fb6be8
commit
db88e40312
@ -84,7 +84,7 @@ def password_validators_help_text_html(password_validators=None):
|
||||
"""
|
||||
help_texts = password_validators_help_texts(password_validators)
|
||||
help_items = [format_html('<li>{}</li>', help_text) for help_text in help_texts]
|
||||
return '<ul>%s</ul>' % ''.join(help_items)
|
||||
return '<ul>%s</ul>' % ''.join(help_items) if help_items else ''
|
||||
|
||||
|
||||
class MinimumLengthValidator(object):
|
||||
|
@ -68,6 +68,10 @@ class PasswordValidationTest(TestCase):
|
||||
self.assertEqual(help_text.count('<li>'), 2)
|
||||
self.assertIn('12 characters', help_text)
|
||||
|
||||
@override_settings(AUTH_PASSWORD_VALIDATORS=[])
|
||||
def test_empty_password_validator_help_text_html(self):
|
||||
self.assertEqual(password_validators_help_text_html(), '')
|
||||
|
||||
|
||||
class MinimumLengthValidatorTest(TestCase):
|
||||
def test_validate(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user