Bug 1222046 - Fix SMTP server responding with timeout due to missing CRLF at end of forwarded HTML message. r=mkmelin,jorgk

This commit is contained in:
Gene Smith 2020-01-11 22:08:33 +01:00
Родитель 031a80891c
Коммит 644e3e0bea
2 изменённых файлов: 9 добавлений и 5 удалений

Просмотреть файл

@ -1264,6 +1264,9 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode,
m_compFields->GetBody(msgBody); m_compFields->GetBody(msgBody);
} }
if (!msgBody.IsEmpty()) { if (!msgBody.IsEmpty()) {
// Ensure body ends in CRLF to avoid SMTP server timeout when sent.
if (!StringEndsWith(msgBody, NS_LITERAL_STRING("\r\n")))
msgBody.AppendLiteral("\r\n");
bool isAsciiOnly = mozilla::IsAsciiNullTerminated( bool isAsciiOnly = mozilla::IsAsciiNullTerminated(
static_cast<const char16_t *>(msgBody.get())); static_cast<const char16_t *>(msgBody.get()));
// Convert body to mail charset // Convert body to mail charset

Просмотреть файл

@ -127,7 +127,8 @@ async function testBodyWithLongLine() {
'<meta http-equiv="content-type" content="text/html; charset=utf-8">' + '<meta http-equiv="content-type" content="text/html; charset=utf-8">' +
"</head><body>" + "</head><body>" +
longMultibyteLine + longMultibyteLine +
"</body></html>"; "</body></html>" +
newline;
fields.body = htmlMessage; fields.body = htmlMessage;
await richCreateMessage(fields, [], identity); await richCreateMessage(fields, [], identity);
checkDraftHeadersAndBody( checkDraftHeadersAndBody(
@ -148,7 +149,7 @@ async function testBodyWithLongLine() {
"Content-Type": "text/plain; charset=UTF-8; format=flowed", "Content-Type": "text/plain; charset=UTF-8; format=flowed",
"Content-Transfer-Encoding": "base64", "Content-Transfer-Encoding": "base64",
}, },
longMultibyteLine + newline // Expected body: The message without the tags. longMultibyteLine + " " + newline + newline // Expected body: The message without the tags.
); );
// Now CJK. // Now CJK.
@ -166,7 +167,7 @@ async function testBodyWithLongLine() {
"Content-Type": "text/html; charset=UTF-8", "Content-Type": "text/html; charset=UTF-8",
"Content-Transfer-Encoding": "base64", "Content-Transfer-Encoding": "base64",
}, },
htmlMessage htmlMessage + newline
); );
// Again, but this time as plain text. // Again, but this time as plain text.
@ -179,7 +180,7 @@ async function testBodyWithLongLine() {
"Content-Type": "text/plain; charset=UTF-8; format=flowed", "Content-Type": "text/plain; charset=UTF-8; format=flowed",
"Content-Transfer-Encoding": "base64", "Content-Transfer-Encoding": "base64",
}, },
longMultibyteLineCJK + newline // Expected body: The message without the tags. longMultibyteLineCJK + " " + newline + newline // Expected body: The message without the tags.
); );
// Now a special test for ISO-2022-JP. // Now a special test for ISO-2022-JP.
@ -199,7 +200,7 @@ async function testBodyWithLongLine() {
"Content-Type": "text/html; charset=ISO-2022-JP", "Content-Type": "text/html; charset=ISO-2022-JP",
"Content-Transfer-Encoding": "base64", "Content-Transfer-Encoding": "base64",
}, },
htmlMessage, htmlMessage + newline,
"ISO-2022-JP" "ISO-2022-JP"
); );