Removed use encoding available only in py3

This commit is contained in:
Vladislav Vlastovskiy 2014-04-14 15:03:50 +04:00 committed by Jason Bittel
parent 644f9b5421
commit bcca9ed0fd

View File

@ -291,15 +291,15 @@ class FileUploadParser(BaseParser):
meta = parser_context['request'].META meta = parser_context['request'].META
disposition = parse_header(meta['HTTP_CONTENT_DISPOSITION'].encode('utf-8')) disposition = parse_header(meta['HTTP_CONTENT_DISPOSITION'].encode('utf-8'))
filename = force_text(disposition[1]['filename'])
if 'filename*' in disposition[1]: if 'filename*' in disposition[1]:
filename_encoded = force_text(disposition[1]['filename*']) filename_encoded = force_text(disposition[1]['filename*'])
try: try:
charset, filename_encoded = filename_encoded.split('\'\'', 1) charset, filename_encoded = filename_encoded.split('\'\'', 1)
filename = urlparse.unquote(filename_encoded, charset) filename = urlparse.unquote(filename_encoded)
except (ValueError, LookupError): except (ValueError, LookupError):
pass filename = force_text(disposition[1]['filename'])
else:
filename = force_text(disposition[1]['filename'])
return filename return filename
except (AttributeError, KeyError): except (AttributeError, KeyError):