Bug 684508 - Line breaks in internet-cited text break UTF-8 quoted-printable characters. r=bienvenu
authorDiomidis Spinellis <dds@aueb.gr>
Thu, 06 Oct 2011 09:46:41 +0100
changeset 9445 1b02fbd2f3b0af778f5aa887bf1bf98cfdc86c45
parent 9444 96ec61738c9614fa6a5999327b5647d574492f45
child 9446 007485db1000460d0ab4515613c47ddf885af42f
push idunknown
push userunknown
push dateunknown
reviewersbienvenu
bugs684508
Bug 684508 - Line breaks in internet-cited text break UTF-8 quoted-printable characters. r=bienvenu
mailnews/compose/src/nsMsgSend.cpp
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -1747,17 +1747,20 @@ nsMsgComposeAndSend::GetBodyFromEditor()
 
   return rv;
 }
 
 // for SMTP, 16k
 // for our internal protocol buffers, 4k
 // for news < 1000
 // so we choose the minimum, because we could be sending and posting this message.
-#define LINE_BREAK_MAX 990
+// Use the exact value, because preceding steps might have trimmed the length
+// close to it, and here e.g. we run the risk of breaking UTF-8 pairs in half.
+// See #684508
+#define LINE_BREAK_MAX (1000 - MSG_LINEBREAK_LEN)
 
 // EnsureLineBreaks() will set m_attachment1_body and m_attachment1_body_length
 nsresult
 nsMsgComposeAndSend::EnsureLineBreaks(const char *body, PRUint32 bodyLen)
 {
   NS_ENSURE_ARG_POINTER(body);
 
   PRUint32 i;