mirror of
https://github.com/python/cpython.git
synced 2025-10-06 23:21:06 +00:00
Merge: #17369: Improve handling of broken RFC2231 values in get_filename.
This commit is contained in:
commit
c489e83432
3 changed files with 28 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue