mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #15182 - Fixed a security issue with ClearableFileInput. Disclosure and new release forthcoming.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15470 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1086,6 +1086,28 @@ class ClearableFileInputTests(TestCase):
|
||||
self.assertEqual(widget.render('myfile', FakeFieldFile()),
|
||||
u'Currently: <a href="something">something</a> <input type="checkbox" name="myfile-clear" id="myfile-clear_id" /> <label for="myfile-clear_id">Clear</label><br />Change: <input type="file" name="myfile" />')
|
||||
|
||||
def test_html_escaped(self):
|
||||
"""
|
||||
A ClearableFileInput should escape name, filename and URL when
|
||||
rendering HTML. Refs #15182.
|
||||
"""
|
||||
|
||||
class StrangeFieldFile(object):
|
||||
url = "something?chapter=1§=2©=3&lang=en"
|
||||
|
||||
def __unicode__(self):
|
||||
return u'''something<div onclick="alert('oops')">.jpg'''
|
||||
|
||||
widget = ClearableFileInput()
|
||||
field = StrangeFieldFile()
|
||||
output = widget.render('my<div>file', field)
|
||||
self.assertFalse(field.url in output)
|
||||
self.assertTrue(u'href="something?chapter=1&sect=2&copy=3&lang=en"' in output)
|
||||
self.assertFalse(unicode(field) in output)
|
||||
self.assertTrue(u'something<div onclick="alert('oops')">.jpg' in output)
|
||||
self.assertTrue(u'my<div>file' in output)
|
||||
self.assertFalse(u'my<div>file' in output)
|
||||
|
||||
def test_clear_input_renders_only_if_not_required(self):
|
||||
"""
|
||||
A ClearableFileInput with is_required=False does not render a clear
|
||||
|
||||
Reference in New Issue
Block a user