summaryrefslogtreecommitdiffstats
path: root/Lib/email/utils.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2014-02-07 20:04:26 (GMT)
committerR David Murray <rdmurray@bitdance.com>2014-02-07 20:04:26 (GMT)
commitc489e83432ef29c9c2a638c4ca290b308e5921e4 (patch)
tree37b9499524794f5aba72cc3d4a5df59d09306609 /Lib/email/utils.py
parentf1e953364ca4ee2715cbeaf85cc67a445770951e (diff)
parent1e949890f618867b7eabc1c08873611e960f5d03 (diff)
downloadcpython-c489e83432ef29c9c2a638c4ca290b308e5921e4.zip
cpython-c489e83432ef29c9c2a638c4ca290b308e5921e4.tar.gz
cpython-c489e83432ef29c9c2a638c4ca290b308e5921e4.tar.bz2
Merge: #17369: Improve handling of broken RFC2231 values in get_filename.
Diffstat (limited to 'Lib/email/utils.py')
-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 25b0d56..95855d8 100644
--- a/Lib/email/utils.py
+++ b/Lib/email/utils.py
@@ -347,6 +347,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)