#35483: ModelMultipleChoiceField with CharField key throws ValueError if data
contains NUL (0x00) characters
-------------------------------------+-------------------------------------
Reporter: Jennifer Richards | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 4.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
ModelMultipleChoiceField null nul |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):
* stage: Unreviewed => Accepted
Comment:
Replicated, thank you for the report!
My failing test if it's useful
{{{#!diff
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
index 3f927cb053..16bdbf8d21 100644
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -2227,6 +2227,12 @@ 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"])
+
def test_model_multiple_choice_run_validators(self):
"""
ModelMultipleChoiceField run given validators (#14144).
}}}
Relates to #28201.
--
Ticket URL: <https://code.djangoproject.com/ticket/35483#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018fbdfed45d-6f39f60d-32f3-455d-99b1-8447ac6f8602-000000%40eu-central-1.amazonses.com.