summaryrefslogtreecommitdiff
path: root/Lib/email
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2014-02-07 15:02:19 -0500
committerR David Murray <rdmurray@bitdance.com>2014-02-07 15:02:19 -0500
commit1e949890f618867b7eabc1c08873611e960f5d03 (patch)
tree04554726253eecaf972503d7f8660a93a2539f98 /Lib/email
parentbd3a11ba34ff57e1a376d6a6eff2e636bdee2160 (diff)
downloadcpython-git-1e949890f618867b7eabc1c08873611e960f5d03.tar.gz
#17369: Improve handling of broken RFC2231 values in get_filename.
This fixes a regression relative to python2.
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/utils.py4
1 files changed, 4 insertions, 0 deletions
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)