Merge pull request #1529 from vlastv/patch-1

Fixed parse file name
This commit is contained in:
Xavier Ordoquy 2014-04-14 10:55:56 +02:00
commit f6329b7b5d
2 changed files with 2 additions and 2 deletions

View File

@ -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

View File

@ -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': {}}