Bug 1510028 - Add null check to avoid crash due to nsDependentCString(null). r=mkmelin
This commit is contained in:
Родитель
e008e05fa1
Коммит
d3986dbe90
|
@ -166,9 +166,9 @@ void nsMsgI18NTextFileCharset(nsACString& aCharset)
|
|||
char * nsMsgI18NEncodeMimePartIIStr(const char *header, bool structured, const char *charset, int32_t fieldnamelen, bool usemime)
|
||||
{
|
||||
// No MIME, convert to the outgoing mail charset.
|
||||
if (false == usemime) {
|
||||
if (!usemime) {
|
||||
nsAutoCString convertedStr;
|
||||
if (NS_SUCCEEDED(nsMsgI18NConvertFromUnicode(nsDependentCString(charset),
|
||||
if (NS_SUCCEEDED(nsMsgI18NConvertFromUnicode(charset ? nsDependentCString(charset) : EmptyCString(),
|
||||
NS_ConvertUTF8toUTF16(header),
|
||||
convertedStr)))
|
||||
return PL_strdup(convertedStr.get());
|
||||
|
|
|
@ -1295,6 +1295,7 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity
|
|||
nsString contentType = (m_composeHTML) ? NS_LITERAL_STRING("text/html"):
|
||||
NS_LITERAL_STRING("text/plain");
|
||||
nsString msgBody;
|
||||
const char *charset = m_compFields->GetCharacterSet();
|
||||
if (m_editor)
|
||||
{
|
||||
// Reset message body previously stored in the compose fields
|
||||
|
@ -1302,8 +1303,6 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity
|
|||
// therefore a casting is required.
|
||||
m_compFields->SetBody((const char *)nullptr);
|
||||
|
||||
const char *charset = m_compFields->GetCharacterSet();
|
||||
|
||||
uint32_t flags = nsIDocumentEncoder::OutputCRLineBreak |
|
||||
nsIDocumentEncoder::OutputLFLineBreak;
|
||||
|
||||
|
@ -1336,7 +1335,7 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity
|
|||
bool isAsciiOnly = NS_IsAscii(static_cast<const char16_t*>(msgBody.get()));
|
||||
// Convert body to mail charset
|
||||
nsCString outCString;
|
||||
rv = nsMsgI18NConvertFromUnicode(nsDependentCString(m_compFields->GetCharacterSet()),
|
||||
rv = nsMsgI18NConvertFromUnicode(charset ? nsDependentCString(charset) : EmptyCString(),
|
||||
msgBody, outCString, true);
|
||||
if (m_compFields->GetForceMsgEncoding())
|
||||
isAsciiOnly = false;
|
||||
|
@ -1353,10 +1352,10 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity
|
|||
{
|
||||
bool disableFallback = false;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch (do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
if (prefBranch)
|
||||
if (prefBranch && charset)
|
||||
{
|
||||
nsCString prefName("mailnews.disable_fallback_to_utf8.");
|
||||
prefName.Append(m_compFields->GetCharacterSet());
|
||||
prefName.Append(charset);
|
||||
prefBranch->GetBoolPref(prefName.get(), &disableFallback);
|
||||
}
|
||||
if (!disableFallback)
|
||||
|
|
|
@ -1273,9 +1273,11 @@ void CMapiMessageHeaders::CHeaderField::GetUnfoldedString(nsString& dest,
|
|||
if (m_fbody_utf8)
|
||||
CopyUTF8toUTF16(unfolded, dest);
|
||||
else
|
||||
nsMsgI18NConvertToUnicode(nsDependentCString(fallbackCharset),
|
||||
unfolded,
|
||||
dest);
|
||||
nsMsgI18NConvertToUnicode(fallbackCharset ?
|
||||
nsDependentCString(fallbackCharset) :
|
||||
EmptyCString(),
|
||||
unfolded,
|
||||
dest);
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
|
|
|
@ -279,7 +279,8 @@ nsresult nsOutlookCompose::ComposeTheMessage(nsMsgDeliverMode mode, CMapiMessage
|
|||
}
|
||||
|
||||
nsCString bodyA;
|
||||
nsMsgI18NConvertFromUnicode(nsDependentCString(msg.GetBodyCharset()), bodyW, bodyA);
|
||||
const char *charset = msg.GetBodyCharset();
|
||||
nsMsgI18NConvertFromUnicode(charset ? nsDependentCString(charset) : EmptyCString(), bodyW, bodyA);
|
||||
|
||||
nsCOMPtr<nsIImportService> impService(do_GetService(NS_IMPORTSERVICE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -349,7 +349,7 @@ CreateCompositionFields(const char *from,
|
|||
|
||||
if (from) {
|
||||
nsMsgI18NConvertRawBytesToUTF16(nsDependentCString(from),
|
||||
nsDependentCString(charset),
|
||||
charset ? nsDependentCString(charset) : EmptyCString(),
|
||||
outString);
|
||||
cFields->SetFrom(outString);
|
||||
}
|
||||
|
@ -361,28 +361,28 @@ CreateCompositionFields(const char *from,
|
|||
|
||||
if (reply_to) {
|
||||
nsMsgI18NConvertRawBytesToUTF16(nsDependentCString(reply_to),
|
||||
nsDependentCString(charset),
|
||||
charset ? nsDependentCString(charset) : EmptyCString(),
|
||||
outString);
|
||||
cFields->SetReplyTo(outString);
|
||||
}
|
||||
|
||||
if (to) {
|
||||
nsMsgI18NConvertRawBytesToUTF16(nsDependentCString(to),
|
||||
nsDependentCString(charset),
|
||||
charset ? nsDependentCString(charset) : EmptyCString(),
|
||||
outString);
|
||||
cFields->SetTo(outString);
|
||||
}
|
||||
|
||||
if (cc) {
|
||||
nsMsgI18NConvertRawBytesToUTF16(nsDependentCString(cc),
|
||||
nsDependentCString(charset),
|
||||
charset ? nsDependentCString(charset) : EmptyCString(),
|
||||
outString);
|
||||
cFields->SetCc(outString);
|
||||
}
|
||||
|
||||
if (bcc) {
|
||||
nsMsgI18NConvertRawBytesToUTF16(nsDependentCString(bcc),
|
||||
nsDependentCString(charset),
|
||||
charset ? nsDependentCString(charset) : EmptyCString(),
|
||||
outString);
|
||||
cFields->SetBcc(outString);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,9 @@ MimeHeaders_convert_header_value(MimeDisplayOptions *opt, nsCString &value,
|
|||
{
|
||||
nsAutoCString output;
|
||||
nsMsgI18NConvertRawBytesToUTF8(value,
|
||||
nsDependentCString(opt->default_charset),
|
||||
opt->default_charset ?
|
||||
nsDependentCString(opt->default_charset) :
|
||||
EmptyCString(),
|
||||
output);
|
||||
value.Assign(output);
|
||||
return;
|
||||
|
|
Загрузка…
Ссылка в новой задаче