Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
2cb6b773
Kaydet (Commit)
2cb6b773
authored
Ock 03, 2018
tarafından
Alvin Lindstam
Kaydeden (comit)
Tim Graham
Ock 03, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28902 -- Fixed password_validators_help_text_html() double escaping.
üst
c86e9b58
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
password_validation.py
django/contrib/auth/password_validation.py
+3
-3
test_validators.py
tests/auth_tests/test_validators.py
+10
-0
No files found.
django/contrib/auth/password_validation.py
Dosyayı görüntüle @
2cb6b773
...
...
@@ -9,7 +9,7 @@ from django.core.exceptions import (
FieldDoesNotExist
,
ImproperlyConfigured
,
ValidationError
,
)
from
django.utils.functional
import
lazy
from
django.utils.html
import
format_html
from
django.utils.html
import
format_html
,
format_html_join
from
django.utils.module_loading
import
import_string
from
django.utils.translation
import
gettext
as
_
,
ngettext
...
...
@@ -81,8 +81,8 @@ def _password_validators_help_text_html(password_validators=None):
in an <ul>.
"""
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
)
if
help_items
else
''
help_items
=
format_html_join
(
''
,
'<li>{}</li>'
,
((
help_text
,)
for
help_text
in
help_texts
))
return
format_html
(
'<ul>{}</ul>'
,
help_items
)
if
help_items
else
''
password_validators_help_text_html
=
lazy
(
_password_validators_help_text_html
,
str
)
...
...
tests/auth_tests/test_validators.py
Dosyayı görüntüle @
2cb6b773
...
...
@@ -13,6 +13,7 @@ from django.core.exceptions import ValidationError
from
django.db
import
models
from
django.test
import
TestCase
,
override_settings
from
django.test.utils
import
isolate_apps
from
django.utils.html
import
conditional_escape
@override_settings
(
AUTH_PASSWORD_VALIDATORS
=
[
...
...
@@ -68,6 +69,15 @@ class PasswordValidationTest(TestCase):
self
.
assertEqual
(
help_text
.
count
(
'<li>'
),
2
)
self
.
assertIn
(
'12 characters'
,
help_text
)
def
test_password_validators_help_text_html_escaping
(
self
):
class
AmpersandValidator
:
def
get_help_text
(
self
):
return
'Must contain &'
help_text
=
password_validators_help_text_html
([
AmpersandValidator
()])
self
.
assertEqual
(
help_text
,
'<ul><li>Must contain &</li></ul>'
)
# help_text is marked safe and therefore unchanged by conditional_escape().
self
.
assertEqual
(
help_text
,
conditional_escape
(
help_text
))
@override_settings
(
AUTH_PASSWORD_VALIDATORS
=
[])
def
test_empty_password_validator_help_text_html
(
self
):
self
.
assertEqual
(
password_validators_help_text_html
(),
''
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment