mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
Added test for encoded filename
This commit is contained in:
parent
8a9f34b838
commit
6e90dad8e3
|
@ -113,3 +113,27 @@ class TestFileUploadParser(TestCase):
|
|||
parser = FileUploadParser()
|
||||
filename = parser.get_filename(self.stream, None, self.parser_context)
|
||||
self.assertEqual(filename, 'file.txt')
|
||||
|
||||
def test_get_encoded_filename(self):
|
||||
parser = FileUploadParser()
|
||||
|
||||
self.__replace_content_disposition('inline; filename*=utf-8\'\'ÀĥƦ.txt')
|
||||
filename = parser.get_filename(self.stream, None, self.parser_context)
|
||||
self.assertEqual(filename, 'ÀĥƦ.txt')
|
||||
|
||||
self.__replace_content_disposition('inline; filename=fallback.txt; filename*=utf-8\'\'ÀĥƦ.txt')
|
||||
filename = parser.get_filename(self.stream, None, self.parser_context)
|
||||
self.assertEqual(filename, 'ÀĥƦ.txt')
|
||||
|
||||
self.__replace_content_disposition('inline; filename=fallback.txt; filename*=utf-8--ÀĥƦ.txt')
|
||||
filename = parser.get_filename(self.stream, None, self.parser_context)
|
||||
self.assertEqual(filename, 'fallback.txt')
|
||||
|
||||
self.__replace_content_disposition('inline; filename=fallback.txt; filename*=WRONG\'\'ÀĥƦ.txt')
|
||||
filename = parser.get_filename(self.stream, None, self.parser_context)
|
||||
self.assertEqual(filename, 'fallback.txt')
|
||||
|
||||
def __replace_content_disposition(self, disposition):
|
||||
self.parser_context['request'].META['HTTP_CONTENT_DISPOSITION'] = disposition
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user