Commit f6329b7b by Xavier Ordoquy

Merge pull request #1529 from vlastv/patch-1

Fixed parse file name
parents 93b9245b 063addab
...@@ -288,7 +288,7 @@ class FileUploadParser(BaseParser): ...@@ -288,7 +288,7 @@ class FileUploadParser(BaseParser):
try: try:
meta = parser_context['request'].META meta = parser_context['request'].META
disposition = parse_header(meta['HTTP_CONTENT_DISPOSITION']) disposition = parse_header(meta['HTTP_CONTENT_DISPOSITION'].encode('utf-8'))
return disposition[1]['filename'] return disposition[1]['filename']
except (AttributeError, KeyError): except (AttributeError, KeyError):
pass pass
...@@ -96,7 +96,7 @@ class TestFileUploadParser(TestCase): ...@@ -96,7 +96,7 @@ class TestFileUploadParser(TestCase):
request = MockRequest() request = MockRequest()
request.upload_handlers = (MemoryFileUploadHandler(),) request.upload_handlers = (MemoryFileUploadHandler(),)
request.META = { request.META = {
'HTTP_CONTENT_DISPOSITION': 'Content-Disposition: inline; filename=file.txt'.encode('utf-8'), 'HTTP_CONTENT_DISPOSITION': 'Content-Disposition: inline; filename=file.txt',
'HTTP_CONTENT_LENGTH': 14, 'HTTP_CONTENT_LENGTH': 14,
} }
self.parser_context = {'request': request, 'kwargs': {}} self.parser_context = {'request': request, 'kwargs': {}}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment