jstedfast / gmime

A C/C++ MIME creation and parser library with support for S/MIME, PGP, and Unix mbox spools.
GNU Lesser General Public License v2.1
111 stars 36 forks source link

quote display names with unterminated qstrings when formatting address lists #139

Closed ehwat closed 1 year ago

ehwat commented 1 year ago

Prior to this change, when formatting address lists without RFC-2047 encoding, the display names are quoted if and only if they contain specials that are preceded by an even number of dquotes without checking wheter the "qstrings" are terminated. This means that the two address lists

=?UTF-8?Q?=22=20=3Cfoo=40bar=2Ecom=3E=2C=20=22?= <test@mail.net>
=?UTF-8?Q?=22=?= <foo@bar.com>, =?UTF-8?Q?=22?= <test@mail.net>

were identically formatted as " <foo@bar.com>, " <test@mail.net>.

With this change, display names are also quoted when they end in an unterminated quoted string. The second address list is now formatted as "\"" <foo@bar.com>, "\"" <test@mail.net>.