mirror of
https://github.com/django/django.git
synced 2025-11-20 11:36:04 +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:
parent
fa78481467
commit
38ad710aba
3 changed files with 23 additions and 1 deletions
|
|
@ -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).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue