From bcca9ed0fd0af251e5a64be0ab7865b396d6b4b8 Mon Sep 17 00:00:00 2001 From: Vladislav Vlastovskiy Date: Mon, 14 Apr 2014 15:03:50 +0400 Subject: [PATCH] Removed use encoding available only in py3 --- rest_framework/parsers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rest_framework/parsers.py b/rest_framework/parsers.py index f285ac975..c67f0088c 100644 --- a/rest_framework/parsers.py +++ b/rest_framework/parsers.py @@ -291,15 +291,15 @@ class FileUploadParser(BaseParser): meta = parser_context['request'].META disposition = parse_header(meta['HTTP_CONTENT_DISPOSITION'].encode('utf-8')) - filename = force_text(disposition[1]['filename']) - if 'filename*' in disposition[1]: filename_encoded = force_text(disposition[1]['filename*']) try: charset, filename_encoded = filename_encoded.split('\'\'', 1) - filename = urlparse.unquote(filename_encoded, charset) + filename = urlparse.unquote(filename_encoded) except (ValueError, LookupError): - pass + filename = force_text(disposition[1]['filename']) + else: + filename = force_text(disposition[1]['filename']) return filename except (AttributeError, KeyError):