Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Escaping and testing output of ErrorDict.

  • Loading branch information...
commit c10feca8f95d228b5ef44c60c229863e91bfcf1d 1 parent c49ff6f
Gregor Müllegger authored
2  django/forms/util.py
View
@@ -27,7 +27,7 @@ def __unicode__(self):
def as_ul(self):
if not self: return u''
return mark_safe(u'<ul class="errorlist">%s</ul>'
- % ''.join([u'<li>%s%s</li>' % (k, force_unicode(v))
+ % ''.join([u'<li>%s%s</li>' % (k, conditional_escape(force_unicode(v)))
for k, v in self.items()]))
def as_text(self):
4 tests/regressiontests/forms/tests/util.py
View
@@ -55,3 +55,7 @@ def __unicode__(self): return u"A very bad error."
'<ul class="errorlist"><li>Example of link: &lt;a href=&quot;http://www.example.com/&quot;&gt;example&lt;/a&gt;</li></ul>')
self.assertEqual(str(ErrorList([mark_safe(example)])),
'<ul class="errorlist"><li>Example of link: <a href="http://www.example.com/">example</a></li></ul>')
+ self.assertEqual(str(ErrorDict({'name': example})),
+ '<ul class="errorlist"><li>nameExample of link: &lt;a href=&quot;http://www.example.com/&quot;&gt;example&lt;/a&gt;</li></ul>')
+ self.assertEqual(str(ErrorDict({'name': mark_safe(example)})),
+ '<ul class="errorlist"><li>nameExample of link: <a href="http://www.example.com/">example</a></li></ul>')
Please sign in to comment.
Something went wrong with that request. Please try again.