Bug 1505315 - Use NS_CopyNativeToUnicode() in MAPI to respect Windows code page. r=emk a=IanN DONTBUILD SEAMONKEY_2_49_ESR_RELBRANCH
authorJorg K <jorgk@jorgk.com>
Sun, 11 Nov 2018 10:57:54 +0100
branchSEAMONKEY_2_49_ESR_RELBRANCH
changeset 28321 8db1b7bb3957e05d5d4d9390a9f1a11fcdd43a07
parent 28320 cb7e2c0d38be0d7b2dfb3136d2de433d9879fa15
child 28322 85b1819ab625bf70a80dddac8d4687f02d805181
push id2136
push userfrgrahl@gmx.net
push dateMon, 15 Jul 2019 16:13:42 +0000
treeherdercomm-esr52@6b30146aa411 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk, IanN
bugs1505315
Bug 1505315 - Use NS_CopyNativeToUnicode() in MAPI to respect Windows code page. r=emk a=IanN DONTBUILD SeaMonkey ESR52 release branch only.
mailnews/mapi/mapihook/src/msgMapiHook.cpp
--- a/mailnews/mapi/mapihook/src/msgMapiHook.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiHook.cpp
@@ -19,16 +19,17 @@
 #include "nsINativeAppSupport.h"
 #include "nsIMsgAccountManager.h"
 #include "nsMsgBaseCID.h"
 #include "nsIStringBundle.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsStringGlue.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"
@@ -494,19 +495,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
@@ -613,43 +613,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);