mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
#17369: Improve handling of broken RFC2231 values in get_filename.
This fixes a regression relative to python2.
This commit is contained in:
parent
bd3a11ba34
commit
1e949890f6
3 changed files with 28 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue