Bug 1444371 - check "is ASCII" before encoding to target charset and remove ISO-2022-JP special case. r=jorgk
authorRin Okuyama <rokuyama@rk.phys.keio.ac.jp>
Fri, 09 Mar 2018 05:08:00 +0100
changeset 23464 57432f5a60e2a2330be1af56c9341f116ff66cf7
parent 23463 d427d8a81a3796ed10bda552368ab3364183abe5
child 23465 fe09f771c2d3bea2c4dd0128f79d6894a7c5657e
push id14178
push usermozilla@jorgk.com
push dateSat, 10 Mar 2018 22:23:38 +0000
treeherdercomm-central@04e68359ee51 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs1444371
Bug 1444371 - check "is ASCII" before encoding to target charset and remove ISO-2022-JP special case. r=jorgk
mailnews/compose/src/nsMsgCompose.cpp
mailnews/compose/src/nsMsgSend.cpp
--- a/mailnews/compose/src/nsMsgCompose.cpp
+++ b/mailnews/compose/src/nsMsgCompose.cpp
@@ -1317,22 +1317,21 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_
     NS_ENSURE_SUCCESS(rv, rv);
   }
   else
   {
     m_compFields->GetBody(msgBody);
   }
   if (!msgBody.IsEmpty())
   {
+    bool isAsciiOnly = NS_IsAscii(static_cast<const char16_t*>(msgBody.get()));
     // Convert body to mail charset
     nsCString outCString;
     rv = nsMsgI18NConvertFromUnicode(nsDependentCString(m_compFields->GetCharacterSet()),
                                      msgBody, outCString, true);
-    bool isAsciiOnly = NS_IsAscii(outCString.get()) &&
-      !nsMsgI18Nstateful_charset(m_compFields->GetCharacterSet());
     if (m_compFields->GetForceMsgEncoding())
       isAsciiOnly = false;
     if (NS_SUCCEEDED(rv) && !outCString.IsEmpty())
     {
       // If the body contains characters outside the repertoire of the current
       // charset, just convert to UTF-8 and be done with it
       // unless disable_fallback_to_utf8 is set for this charset.
       if (NS_ERROR_UENC_NOMAPPING == rv)
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -1556,22 +1556,21 @@ nsMsgComposeAndSend::GetBodyFromEditor()
   nsCString attachment1_body;
 
   // Convert body to mail charset
   nsCString    outCString;
   const char  *aCharset = mCompFields->GetCharacterSet();
 
   if (aCharset && *aCharset)
   {
+    bool isAsciiOnly = NS_IsAscii(bodyText);
     rv = nsMsgI18NConvertFromUnicode(nsDependentCString(aCharset),
                                      nsDependentString(bodyText),
                                      outCString,
                                      true);
-    bool isAsciiOnly = NS_IsAscii(outCString.get()) &&
-      !nsMsgI18Nstateful_charset(mCompFields->GetCharacterSet());
     if (mCompFields->GetForceMsgEncoding())
       isAsciiOnly = false;
     mCompFields->SetBodyIsAsciiOnly(isAsciiOnly);
 
     // If the body contains characters outside the current mail charset,
     // convert to UTF-8.
     if (NS_ERROR_UENC_NOMAPPING == rv)
     {