Bug 1521007 - Follow-up: also check for UTF-8 when copying file path. r+a=jorgk
authorMike Kaganski <mikekaganski@gmail.com>
Sat, 19 Jan 2019 03:38:00 +0100
changeset 33102 2c97e77600fbe828bdf012098cd7dbab64a4aa47
parent 33101 18b2c9cbcf7c3adc5c1e2c89e401363987c92174
child 33103 b96e1949a0d5a1de17ef6617693863791019c539
push id2364
push usermozilla@jorgk.com
push dateTue, 22 Jan 2019 16:44:41 +0000
treeherdercomm-beta@7dba53ed25d3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1521007
Bug 1521007 - Follow-up: also check for UTF-8 when copying file path. r+a=jorgk
mailnews/mapi/mapihook/src/msgMapiHook.cpp
--- a/mailnews/mapi/mapihook/src/msgMapiHook.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiHook.cpp
@@ -361,21 +361,27 @@ nsresult nsMapiHook::HandleAttachments (
     nsCOMPtr <nsIFile> pTempDir = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv) ;
     if (NS_FAILED(rv) || (!pTempDir) ) return rv ;
 
     for (int i=0 ; i < aFileCount ; i++)
     {
         if (aFiles[i].lpszPathName)
         {
             // check if attachment exists
-            pFile->InitWithNativePath(nsDependentCString((const char*)aFiles[i].lpszPathName));
+            if (!aIsUTF8)
+              pFile->InitWithNativePath(nsDependentCString(aFiles[i].lpszPathName));
+            else
+              pFile->InitWithPath(NS_ConvertUTF8toUTF16(aFiles[i].lpszPathName));
 
             bool bExist ;
             rv = pFile->Exists(&bExist) ;
-            MOZ_LOG(MAPI, mozilla::LogLevel::Debug, ("nsMapiHook::HandleAttachments: filename: %s path: %s exists = %s \n", (const char*)aFiles[i].lpszFileName, (const char*)aFiles[i].lpszPathName, bExist ? "true" : "false"));
+            MOZ_LOG(MAPI, mozilla::LogLevel::Debug,
+              ("nsMapiHook::HandleAttachments: filename: %s path: %s exists = %s\n",
+               (const char*)aFiles[i].lpszFileName,
+               (const char*)aFiles[i].lpszPathName, bExist ? "true" : "false"));
             if (NS_FAILED(rv) || (!bExist) ) return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST ;
 
             //Temp Directory
             nsCOMPtr <nsIFile> pTempDir;
             NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(pTempDir));
 
             // create a new sub directory called moz_mapi underneath the temp directory
             pTempDir->AppendRelativePath(NS_LITERAL_STRING("moz_mapi"));