mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #15181 -- Ensure that special characters are escaped when querying for the URL of an uploaded file. Thanks to e.generalov for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15409 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -204,6 +204,15 @@ class FileStorageTests(unittest.TestCase):
|
||||
self.assertEqual(self.storage.url('test.file'),
|
||||
'%s%s' % (self.storage.base_url, 'test.file'))
|
||||
|
||||
# should encode special chars except ~!*()'
|
||||
# like encodeURIComponent() JavaScript function do
|
||||
self.assertEqual(self.storage.url(r"""~!*()'@#$%^&*abc`+=.file"""),
|
||||
"""/test_media_url/~!*()'%40%23%24%25%5E%26*abc%60%2B%3D.file""")
|
||||
|
||||
# should stanslate os path separator(s) to the url path separator
|
||||
self.assertEqual(self.storage.url("""a/b\\c.file"""),
|
||||
"""/test_media_url/a/b/c.file""")
|
||||
|
||||
self.storage.base_url = None
|
||||
self.assertRaises(ValueError, self.storage.url, 'test.file')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user