diff options
author | R David Murray <rdmurray@bitdance.com> | 2014-02-07 20:02:19 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2014-02-07 20:02:19 (GMT) |
commit | 1e949890f618867b7eabc1c08873611e960f5d03 (patch) | |
tree | 04554726253eecaf972503d7f8660a93a2539f98 /Lib/email/utils.py | |
parent | bd3a11ba34ff57e1a376d6a6eff2e636bdee2160 (diff) | |
download | cpython-1e949890f618867b7eabc1c08873611e960f5d03.zip cpython-1e949890f618867b7eabc1c08873611e960f5d03.tar.gz cpython-1e949890f618867b7eabc1c08873611e960f5d03.tar.bz2 |
#17369: Improve handling of broken RFC2231 values in get_filename.
This fixes a regression relative to python2.
Diffstat (limited to 'Lib/email/utils.py')
-rw-r--r-- | Lib/email/utils.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/email/utils.py b/Lib/email/utils.py index 93a625c..f76c21e 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) |