Bug 1521007 - Follow-up: also check for UTF-8 when copying file path. r=jorgk DONTBUILD
authorMike Kaganski <mikekaganski@gmail.com>
Sat, 19 Jan 2019 03:38:00 +0100
changeset 33391 609c28fdc2a7
parent 33390 e50aae192485
child 33392 1948a0ff606a
push id2368
push userclokep@gmail.com
push dateMon, 28 Jan 2019 21:12:50 +0000
treeherdercomm-beta@56d23c07d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs1521007
Bug 1521007 - Follow-up: also check for UTF-8 when copying file path. r=jorgk DONTBUILD
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"));