Bug 1224600 - utf-8 + comma in To line breaks File | Send Unsent Messages. r=rkent

This commit is contained in:
Magnus Melin 2016-01-19 22:01:50 +02:00
Родитель 65748b535d
Коммит 3a9739cbbc
3 изменённых файлов: 7 добавлений и 29 удалений

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

@ -516,57 +516,34 @@ nsMsgSendLater::CompleteMailFileSend()
if (!created)
return NS_ERROR_FAILURE;
// Get the recipients...
nsCString recips;
nsCString ccList;
if (NS_FAILED(mMessage->GetRecipients(getter_Copies(recips))))
return NS_ERROR_UNEXPECTED;
else
mMessage->GetCcList(getter_Copies(ccList));
nsCOMPtr<nsIMsgCompFields> compFields = do_CreateInstance(NS_MSGCOMPFIELDS_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIMsgSend> pMsgSend = do_CreateInstance(NS_MSGSEND_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIMimeConverter> mimeConverter = do_GetService(NS_MIME_CONVERTER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
// Since we have already parsed all of the headers, we are simply going to
// set the composition fields and move on.
//
nsCString author;
mMessage->GetAuthor(getter_Copies(author));
nsMsgCompFields * fields = (nsMsgCompFields *)compFields.get();
nsCString decodedString;
// decoded string is null if the input is not MIME encoded
mimeConverter->DecodeMimeHeaderToUTF8(author, nullptr, false, true,
decodedString);
fields->SetFrom(decodedString.IsEmpty() ? author.get() : decodedString.get());
fields->SetFrom(author.get());
if (m_to)
{
mimeConverter->DecodeMimeHeaderToUTF8(nsDependentCString(m_to), nullptr,
false, true, decodedString);
fields->SetTo(decodedString.IsEmpty() ? m_to : decodedString.get());
fields->SetTo(m_to);
}
if (m_bcc)
{
mimeConverter->DecodeMimeHeaderToUTF8(nsDependentCString(m_bcc), nullptr,
false, true, decodedString);
fields->SetBcc(decodedString.IsEmpty() ? m_bcc : decodedString.get());
fields->SetBcc(m_bcc);
}
if (m_fcc)
{
mimeConverter->DecodeMimeHeaderToUTF8(nsDependentCString(m_fcc), nullptr,
false, true, decodedString);
fields->SetFcc(decodedString.IsEmpty() ? m_fcc : decodedString.get());
fields->SetFcc(m_fcc);
}
if (m_newsgroups)

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

@ -1,5 +1,5 @@
From: Invalid User <invalid@foo.invalid>
To: Invalid User <to@foo.invalid>
To: =?UTF-8?B?RnLDqcOpZGxlLCBUZXN0?= <to@foo.invalid>
Subject: Big email
012345678901234567890123456789012345678901234567890123456789

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

@ -25,6 +25,7 @@ var testFile = do_get_file("data/429891_testcase.eml");
var kSender = "from@foo.invalid";
var kTo = "to@foo.invalid";
var kToEncodedDisplayName = "=?UTF-8?B?RnLDqcOpZGxlLCBUZXN0?="; // "Fréédle, Test"
var msgSendLater = Cc["@mozilla.org/messengercompose/sendlater;1"]
.getService(Ci.nsIMsgSendLater);
@ -207,7 +208,7 @@ function run_test() {
.createInstance(Ci.nsIMsgCompFields);
compFields.from = identity.email;
compFields.to = kTo;
compFields.to = kToEncodedDisplayName + " <" + kTo + ">";
var msgSend = Cc["@mozilla.org/messengercompose/send;1"]
.createInstance(Ci.nsIMsgSend);