diff -r fcc09d9ee7d4 Lib/email/utils.py --- a/Lib/email/utils.py Mon Dec 19 18:51:37 2016 +0200 +++ b/Lib/email/utils.py Thu Dec 22 10:33:41 2016 -0500 @@ -319,7 +319,7 @@ def collapse_rfc2231_value(value, errors='replace', fallback_charset='us-ascii'): if not isinstance(value, tuple) or len(value) != 3: - return unquote(value) + return value # While value comes to us as a unicode string, we need it to be a bytes # object. We do not want bytes() normal utf-8 decoder, we want a straight # interpretation of the string as character bytes. diff -r fcc09d9ee7d4 Lib/test/test_email/test_email.py --- a/Lib/test/test_email/test_email.py Mon Dec 19 18:51:37 2016 +0200 +++ b/Lib/test/test_email/test_email.py Thu Dec 22 10:33:41 2016 -0500 @@ -5177,6 +5177,27 @@ msg = email.message_from_string(m) self.assertEqual(msg.get_boundary(), 'This is even more ***fun*** is it not.pdf') + + def test_rfc2231_multiple_quote_boundary(self): + m = '''\ +Content-Type: multipart/alternative; +\tboundary*0*="<>') + def test_rfc2231_multiple_quote_boundary2(self): + m = '''\ +Content-Type: multipart/alternative; +\tboundary="<>"; + +''' + msg = email.message_from_string(m) + self.assertEqual(msg.get_boundary(), + '<>') def test_rfc2231_no_language_or_charset_in_charset(self): # This is a nonsensical charset value, but tests the code anyway