From e65fea9292ffdeb9bb76062f6cb2a5ff514ae969 Mon Sep 17 00:00:00 2001 From: 007 <007gzs@gmail.com> Date: Fri, 21 Feb 2020 13:25:22 +0800 Subject: Fixed #31293 -- Allowed MultiPartParser to handle double-quoted encoded headers. --- django/http/multipartparser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'django') diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py index fd8fce8b4d..33d8814241 100644 --- a/django/http/multipartparser.py +++ b/django/http/multipartparser.py @@ -664,12 +664,12 @@ def parse_header(line): if p.count(b"'") == 2: has_encoding = True value = p[i + 1:].strip() - if has_encoding: - encoding, lang, value = value.split(b"'") - value = unquote(value.decode(), encoding=encoding.decode()) if len(value) >= 2 and value[:1] == value[-1:] == b'"': value = value[1:-1] value = value.replace(b'\\\\', b'\\').replace(b'\\"', b'"') + if has_encoding: + encoding, lang, value = value.split(b"'") + value = unquote(value.decode(), encoding=encoding.decode()) pdict[name] = value return key, pdict -- cgit v1.3