зеркало из https://github.com/mozilla/gecko-dev.git
Changed unicode conversion for mail send.
Added a fallback for unmapped characters, moved entity conversion after the unicode conversion as the fallback, avoided to convert twice for text/html case, part of bug fix 15475, r=rhp.
This commit is contained in:
Родитель
177a1382c5
Коммит
7063b0ce6c
|
@ -411,37 +411,36 @@ nsresult nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode,
|
|||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (m_editor && m_compFields)
|
||||
if (m_editor && m_compFields && !m_composeHTML)
|
||||
{
|
||||
const char contentType[] = "text/plain";
|
||||
nsAutoString msgBody;
|
||||
PRUnichar *bodyText = NULL;
|
||||
nsString format;
|
||||
PRUint32 flags = 0;
|
||||
if (m_composeHTML)
|
||||
format = "text/html";
|
||||
else
|
||||
{
|
||||
flags = nsIDocumentEncoder::OutputFormatted;
|
||||
format = "text/plain";
|
||||
}
|
||||
m_editor->GetContentsAs(format.GetUnicode(), flags, &bodyText);
|
||||
nsString format(contentType);
|
||||
PRUint32 flags = nsIDocumentEncoder::OutputFormatted;
|
||||
|
||||
msgBody = bodyText;
|
||||
delete [] bodyText;
|
||||
rv = m_editor->GetContentsAs(format.GetUnicode(), flags, &bodyText);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && NULL != bodyText)
|
||||
{
|
||||
msgBody = bodyText;
|
||||
nsAllocator::Free(bodyText);
|
||||
|
||||
// Convert body to mail charset not to utf-8 (because we don't manipulate body text)
|
||||
char *outCString;
|
||||
nsString aCharset = m_compFields->GetCharacterSet();
|
||||
if (NS_SUCCEEDED(ConvertFromUnicode(aCharset, msgBody, &outCString)))
|
||||
{
|
||||
m_compFields->SetBody(outCString);
|
||||
PR_Free(outCString);
|
||||
}
|
||||
else
|
||||
m_compFields->SetBody(nsAutoCString(msgBody));
|
||||
// Convert body to mail charset not to utf-8 (because we don't manipulate body text)
|
||||
char *outCString = NULL;
|
||||
rv = nsMsgI18NSaveAsCharset(contentType, m_compFields->GetCharacterSet(),
|
||||
msgBody.GetUnicode(), &outCString);
|
||||
if (NS_SUCCEEDED(rv) && NULL != outCString)
|
||||
{
|
||||
m_compFields->SetBody(outCString);
|
||||
PR_Free(outCString);
|
||||
}
|
||||
else
|
||||
m_compFields->SetBody(nsAutoCString(msgBody));
|
||||
}
|
||||
}
|
||||
|
||||
rv = _SendMsg(deliverMode, identity, callback);
|
||||
|
||||
rv = _SendMsg(deliverMode, identity, callback);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
ShowWindow(PR_TRUE);
|
||||
|
|
|
@ -1296,14 +1296,9 @@ nsMsgComposeAndSend::GetBodyFromEditor()
|
|||
{
|
||||
// Convert to entities.
|
||||
// If later Editor generates entities then we can remove this.
|
||||
PRBool bSendEntity = PR_FALSE;
|
||||
nsString bodyTextEntity;
|
||||
if (NS_SUCCEEDED(nsMsgI18NConvertToEntity(bodyText, &bodyTextEntity))) {
|
||||
bSendEntity = PR_TRUE;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(ConvertFromUnicode(aCharset, bSendEntity ? bodyTextEntity.GetUnicode() : bodyText, &outCString)))
|
||||
{
|
||||
char charset[65];
|
||||
nsresult rv = nsMsgI18NSaveAsCharset(attachment1_type, aCharset.ToCString(charset, 65), bodyText, &outCString);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PR_FREEIF(attachment1_body);
|
||||
attachment1_body = outCString;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче