Skip to content

Commit 93e7c1a

Browse files
gh-XXXXX: Fix email.utils.collapse_rfc2231_value crash on non-3-tuples
Passing a tuple of length != 3 fell through to unquote(value) which calls .startswith() on the tuple, raising AttributeError. Handle non-3-tuples explicitly before calling unquote.
1 parent 5944a53 commit 93e7c1a

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Lib/email/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,8 @@ def decode_params(params):
449449
def collapse_rfc2231_value(value, errors='replace',
450450
fallback_charset='us-ascii'):
451451
if not isinstance(value, tuple) or len(value) != 3:
452+
if isinstance(value, tuple):
453+
return str(value)
452454
return unquote(value)
453455
# While value comes to us as a unicode string, we need it to be a bytes
454456
# object. We do not want bytes() normal utf-8 decoder, we want a straight

0 commit comments

Comments
 (0)