Ticket #16684: 16684.diff
File 16684.diff, 1.8 KB (added by , 13 years ago) |
---|
-
tests/regressiontests/forms/tests/regressions.py
class FormsRegressionsTestCase(TestCase): 18 18 19 19 self.assertEqual(TestForm(auto_id=False).as_p(), u'<p>F1: <input type="text" class="special" name="f1" maxlength="10" /></p>\n<p>F2: <input type="text" class="special" name="f2" /></p>') 20 20 21 def test_regression_16684(self): 22 """ 23 Test for bug #16684 - make sure to escape CSS class identifiers 24 """ 25 class TestForm(Form): 26 required_css_class = r'\&required' 27 28 text = CharField() 29 30 form = TestForm({ 'text': 'test' }) 31 self.assertEqual(unicode(form.as_table()), u'<tr class="\\&required"><th><label for="id_text">Text:</label></th><td><input type="text" name="text" value="test" id="id_text" /></td></tr>') 32 21 33 def test_regression_3600(self): 22 34 # Tests for form i18n # 23 35 # There were some problems with form translations in #3600 -
django/forms/forms.py
class BaseForm(StrAndUnicode): 153 153 # CSS classes applied. 154 154 css_classes = bf.css_classes() 155 155 if css_classes: 156 html_class_attr = ' class="%s"' % c ss_classes156 html_class_attr = ' class="%s"' % conditional_escape(css_classes) 157 157 158 158 if errors_on_separate_row and bf_errors: 159 159 output.append(error_row % force_unicode(bf_errors))