Bug 1505315 - Use NS_CopyNativeToUnicode() in MAPI to respect Windows code page. r=emk a=jorgk
authorJorg K <jorgk@jorgk.com>
Sun, 11 Nov 2018 10:57:54 +0100
changeset 33494 0efafe38b54055d9350fb7714600cf1cd0c562b4
parent 33493 c40e51472fab2871b47789f9d9be2b3c2441e62e
child 33495 53151ac733ae41d6620ac80a6d170ad1cc12b7ac
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersemk, jorgk
bugs1505315
Bug 1505315 - Use NS_CopyNativeToUnicode() in MAPI to respect Windows code page. r=emk a=jorgk
mailnews/mapi/mapihook/src/msgMapiHook.cpp
--- a/mailnews/mapi/mapihook/src/msgMapiHook.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiHook.cpp
@@ -15,26 +15,26 @@
 #include "mozIDOMWindow.h"
 #include "nsIMsgAccountManager.h"
 #include "nsMsgBaseCID.h"
 #include "nsIStringBundle.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsString.h"
 #include "nsUnicharUtils.h"
+#include "nsNativeCharsetUtils.h"
 #include "nsIMsgAttachment.h"
 #include "nsIMsgCompFields.h"
 #include "nsIMsgComposeParams.h"
 #include "nsIMsgCompose.h"
 #include "nsMsgCompCID.h"
 #include "nsIMsgSend.h"
 #include "nsIMsgComposeService.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
-#include "nsMsgI18N.h"
 #include "msgMapi.h"
 #include "msgMapiHook.h"
 #include "msgMapiSupport.h"
 #include "msgMapiMain.h"
 #include "nsThreadUtils.h"
 #include "nsMsgUtils.h"
 #include "nsNetUtil.h"
 #include "mozilla/Services.h"
@@ -473,19 +473,18 @@ nsresult nsMapiHook::HandleAttachments (
             // leafName already contains a unicode leafName from lpszPathName. If we were given
             // a value for lpszFileName, use it. Otherwise stick with leafName
             if (aFiles[i].lpszFileName)
             {
               nsAutoString wholeFileName;
                 if (aIsUnicode)
                     wholeFileName.Assign(aFiles[i].lpszFileName);
                 else
-                    nsMsgI18NConvertToUnicode(nsMsgI18NFileSystemCharset(),
-                                              nsDependentCString((char *) aFiles[i].lpszFileName),
-                                              wholeFileName);
+                    NS_CopyNativeToUnicode(nsDependentCString((char *) aFiles[i].lpszFileName),
+                                           wholeFileName);
                 // need to find the last '\' and find the leafname from that.
                 int32_t lastSlash = wholeFileName.RFindChar(char16_t('\\'));
                 if (lastSlash != kNotFound)
                   leafName.Assign(Substring(wholeFileName, lastSlash + 1));
                 else
                   leafName.Assign(wholeFileName);
             }
             else
@@ -592,43 +591,36 @@ nsresult nsMapiHook::PopulateCompFieldsW
 
   // set To, Cc, Bcc
   aCompFields->SetTo (To) ;
   aCompFields->SetCc (Cc) ;
   aCompFields->SetBcc (Bcc) ;
 
   MOZ_LOG(MAPI, mozilla::LogLevel::Debug, ("to: %s cc: %s bcc: %s \n", NS_ConvertUTF16toUTF8(To).get(), NS_ConvertUTF16toUTF8(Cc).get(), NS_ConvertUTF16toUTF8(Bcc).get()));
 
-  nsAutoCString platformCharSet;
   // set subject
   if (aMessage->lpszSubject)
   {
     nsAutoString Subject ;
-    if (platformCharSet.IsEmpty())
-      platformCharSet = nsMsgI18NFileSystemCharset();
-    rv = nsMsgI18NConvertToUnicode(platformCharSet,
-                                   nsDependentCString((char *) aMessage->lpszSubject),
-                                   Subject);
+    rv = NS_CopyNativeToUnicode(nsDependentCString((char *) aMessage->lpszSubject),
+                                Subject);
     if (NS_FAILED(rv)) return rv;
     aCompFields->SetSubject(Subject);
   }
 
   // handle attachments as File URL
   rv = HandleAttachments (aCompFields, aMessage->nFileCount, aMessage->lpFiles, false) ;
   if (NS_FAILED(rv)) return rv ;
 
   // set body
   if (aMessage->lpszNoteText)
   {
     nsAutoString Body ;
-    if (platformCharSet.IsEmpty())
-      platformCharSet = nsMsgI18NFileSystemCharset();
-    rv = nsMsgI18NConvertToUnicode(platformCharSet,
-                                   nsDependentCString((char *) aMessage->lpszNoteText),
-                                   Body);
+    rv = NS_CopyNativeToUnicode(nsDependentCString((char *) aMessage->lpszNoteText),
+                                Body);
     if (NS_FAILED(rv)) return rv ;
     if (Body.IsEmpty() || Body.Last() != '\n')
       Body.AppendLiteral(CRLF);
 
     // This is needed when Simple MAPI is used without a compose window.
     // See bug 1366196.
     if (Body.Find("<html>") == kNotFound)
       aCompFields->SetForcePlainText(true);