mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Fix encoded filename parsing to allow for lang
This commit is contained in:
parent
bcd8a24db1
commit
c8e475023c
|
@ -303,7 +303,7 @@ class FileUploadParser(BaseParser):
|
|||
"""
|
||||
encoded_filename = force_text(disposition['filename*'])
|
||||
try:
|
||||
charset, filename = encoded_filename.split('\'\'', 1)
|
||||
charset, lang, filename = encoded_filename.split('\'', 2)
|
||||
filename = urlparse.unquote(filename)
|
||||
except (ValueError, LookupError):
|
||||
filename = force_text(disposition['filename'])
|
||||
|
|
|
@ -127,6 +127,10 @@ class TestFileUploadParser(TestCase):
|
|||
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\'en-us\'ÀĥƦ.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')
|
||||
|
|
Loading…
Reference in New Issue
Block a user