diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2011-02-04 14:43:10 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2011-02-04 14:43:10 +0000 |
| commit | 090ff642043a2ca7d69e475f721eab4d68f6572b (patch) | |
| tree | b96857a53d27c9ad8fce5d6e169c02093d90f3f2 /tests | |
| parent | 514c0b5eb48ee23f656ab433ff35f01741d2c3a0 (diff) | |
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
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/file_storage/tests.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py index 44466fe975..a4f118f2df 100644 --- a/tests/regressiontests/file_storage/tests.py +++ b/tests/regressiontests/file_storage/tests.py @@ -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') |
