andris9/mailcomposer — pull request #1 by huancz (2012-03-01 22:46:15+00:00)
Title: bug in breaking encoded mimewords into individual lines

Test code:

var e = new (require('./mailcomposer').MailComposer);
console.log(e._encodeMimeWord('INFO: Uživatel XXXXXX XěXXX přidal...', 'Q', 50).replace(/ /g, '\r\n'));

This produces following output:

=?UTF-8?Q?INFO:_U=C5=BEivatel_XXXXXX_X=C4=9BXXX_p=?=
=?UTF-8?Q?C5=99idal...?=

That lone = (part of =C5 byte) on first line, when put in subject header, causes Thunderbird to consider the whole encoding as invalid and display the subject as plaintext instead of decoding it. Another (webmail) client can parse most of it, but result is "INFO: Uživatel XXXXXX X=C5XXX přidal..." which is not right either.

This patch is probably somewhat inefficient with all the string copying and spliting, but at least all mail clients I tried understand it's output.