From 1e949890f618867b7eabc1c08873611e960f5d03 Mon Sep 17 00:00:00 2001 From: R David Murray Date: Fri, 7 Feb 2014 15:02:19 -0500 Subject: #17369: Improve handling of broken RFC2231 values in get_filename. This fixes a regression relative to python2. --- Lib/email/utils.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Lib/email/utils.py') diff --git a/Lib/email/utils.py b/Lib/email/utils.py index 93a625c8b4..f76c21eb1b 100644 --- a/Lib/email/utils.py +++ b/Lib/email/utils.py @@ -337,6 +337,10 @@ def collapse_rfc2231_value(value, errors='replace', # object. We do not want bytes() normal utf-8 decoder, we want a straight # interpretation of the string as character bytes. charset, language, text = value + if charset is None: + # Issue 17369: if charset/lang is None, decode_rfc2231 couldn't parse + # the value, so use the fallback_charset. + charset = fallback_charset rawbytes = bytes(text, 'raw-unicode-escape') try: return str(rawbytes, charset, errors) -- cgit v1.2.1