summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Catton <acatton@fusionbox.com>2015-09-25 15:32:23 -0600
committerTim Graham <timograham@gmail.com>2015-09-28 15:30:16 -0400
commit53ccffdb8c8e47a4d4304df453d8c79a9be295ab (patch)
treea91892e8fa32ce7045ae70f8f6ac008568b7d305
parentc14b6b52ff131db263bf06a02f903a73390975da (diff)
Refs #16860 -- Fixed password help text when there aren't any validators.
This avoids creating an empty list which is invalid HTML 4.
-rw-r--r--django/contrib/auth/password_validation.py2
-rw-r--r--tests/auth_tests/test_validators.py4
2 files changed, 5 insertions, 1 deletions
diff --git a/django/contrib/auth/password_validation.py b/django/contrib/auth/password_validation.py
index efad0d72a6..332d76c845 100644
--- a/django/contrib/auth/password_validation.py
+++ b/django/contrib/auth/password_validation.py
@@ -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):
diff --git a/tests/auth_tests/test_validators.py b/tests/auth_tests/test_validators.py
index e70feb727d..a9f47eac1f 100644
--- a/tests/auth_tests/test_validators.py
+++ b/tests/auth_tests/test_validators.py
@@ -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):