mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #35483 -- Added NUL (0x00) character validation to ModelChoiceFields.
Applied the ProhibitNullCharactersValidator to ModelChoiceField and ModelMultipleChoiceField. Co-authored-by: Viktor Paripás <viktor.paripas@gmail.com> Co-authored-by: Vasyl Dizhak <vasyl@dizhak.com> Co-authored-by: Arthur Vasconcelos <vasconcelos.arthur@gmail.com>
This commit is contained in:
committed by
Sarah Boyce
parent
fa78481467
commit
38ad710aba
@@ -2227,6 +2227,15 @@ class ModelMultipleChoiceFieldTests(TestCase):
|
||||
f = forms.ModelMultipleChoiceField(queryset=Writer.objects.all())
|
||||
self.assertNumQueries(1, f.clean, [p.pk for p in persons[1:11:2]])
|
||||
|
||||
def test_model_multiple_choice_null_characters(self):
|
||||
f = forms.ModelMultipleChoiceField(queryset=ExplicitPK.objects.all())
|
||||
msg = "Null characters are not allowed."
|
||||
with self.assertRaisesMessage(ValidationError, msg):
|
||||
f.clean(["\x00something"])
|
||||
|
||||
with self.assertRaisesMessage(ValidationError, msg):
|
||||
f.clean(["valid", "\x00something"])
|
||||
|
||||
def test_model_multiple_choice_run_validators(self):
|
||||
"""
|
||||
ModelMultipleChoiceField run given validators (#14144).
|
||||
|
||||
Reference in New Issue
Block a user