mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixes #8593 -- better handling of safe_join case sensitivity on windows. Thanks for the initial patch, ramiro.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16267 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
dab90dd429
commit
fcf7fbc68c
6 changed files with 71 additions and 14 deletions
|
@ -278,6 +278,37 @@ class FileUploadTests(TestCase):
|
|||
# CustomUploadError is the error that should have been raised
|
||||
self.assertEqual(err.__class__, uploadhandler.CustomUploadError)
|
||||
|
||||
def test_filename_case_preservation(self):
|
||||
"""
|
||||
The storage backend shouldn't mess with the case of the filenames
|
||||
uploaded.
|
||||
"""
|
||||
# Synthesize the contents of a file upload with a mixed case filename
|
||||
# so we don't have to carry such a file in the Django tests source code
|
||||
# tree.
|
||||
vars = {'boundary': 'oUrBoUnDaRyStRiNg'}
|
||||
post_data = [
|
||||
'--%(boundary)s',
|
||||
'Content-Disposition: form-data; name="file_field"; '
|
||||
'filename="MiXeD_cAsE.txt"',
|
||||
'Content-Type: application/octet-stream',
|
||||
'',
|
||||
'file contents\n'
|
||||
'',
|
||||
'--%(boundary)s--\r\n',
|
||||
]
|
||||
response = self.client.post(
|
||||
'/file_uploads/filename_case/',
|
||||
'\r\n'.join(post_data) % vars,
|
||||
'multipart/form-data; boundary=%(boundary)s' % vars
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
id = int(response.content)
|
||||
obj = FileModel.objects.get(pk=id)
|
||||
# The name of the file uploaded and the file stored in the server-side
|
||||
# shouldn't differ.
|
||||
self.assertEqual(os.path.basename(obj.testfile.path), 'MiXeD_cAsE.txt')
|
||||
|
||||
class DirectoryCreationTests(unittest.TestCase):
|
||||
"""
|
||||
Tests for error handling during directory creation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue