diff options
| author | Daniil <daniilr@users.noreply.github.com> | 2017-12-11 22:30:47 +1000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-12-11 07:30:47 -0500 |
| commit | 7c7bc6391a3e83566f9ace59955e63503bc76cee (patch) | |
| tree | 91ea930d8288f33c2ce977d58de3368229066875 /tests | |
| parent | d13a9e44ded4e93570c6ba42ec84e45ddca2505b (diff) | |
Fixed #28874 -- Prevented double escaping of errors on hidden form fields.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/forms_tests/tests/test_forms.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index 3f4fb4e10b..a6b157f044 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -3398,6 +3398,27 @@ Good luck picking a username that doesn't already exist.</p> <div class="errorlist"><div class="error">This field is required.</div></div> <p>Comment: <input type="text" name="comment" required /></p>""") + def test_error_escaping(self): + class TestForm(Form): + hidden = CharField(widget=HiddenInput(), required=False) + visible = CharField() + + def clean_hidden(self): + raise ValidationError('Foo & "bar"!') + + clean_visible = clean_hidden + + form = TestForm({'hidden': 'a', 'visible': 'b'}) + form.is_valid() + self.assertHTMLEqual( + form.as_ul(), + '<li><ul class="errorlist nonfield"><li>(Hidden field hidden) Foo & "bar"!</li></ul></li>' + '<li><ul class="errorlist"><li>Foo & "bar"!</li></ul>' + '<label for="id_visible">Visible:</label> ' + '<input type="text" name="visible" value="b" id="id_visible" required />' + '<input type="hidden" name="hidden" value="a" id="id_hidden" /></li>' + ) + def test_baseform_repr(self): """ BaseForm.__repr__() should contain some basic information about the |
