Bug 1445853 - Work-around for mailbox:// URL not supporting UTF-8 paths. r=jorgk a=jorgk
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Sat, 17 Mar 2018 19:16:45 +0900
changeset 30476 43daf17883d1e37688af61ed84f0a1a87ad85324
parent 30475 7b2b70b0736966d566fc92ec2e832a7217b20eba
child 30477 01c6b254c2037c36de2fe15a1cc4bc335f34713e
push id2146
push usermozilla@jorgk.com
push dateMon, 19 Mar 2018 08:34:14 +0000
treeherdercomm-beta@3f6164d3285b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk, jorgk
bugs1445853
Bug 1445853 - Work-around for mailbox:// URL not supporting UTF-8 paths. r=jorgk a=jorgk
mailnews/local/src/nsLocalUtils.cpp
mailnews/local/src/nsMailboxService.cpp
--- a/mailnews/local/src/nsLocalUtils.cpp
+++ b/mailnews/local/src/nsLocalUtils.cpp
@@ -10,16 +10,17 @@
 #include "nsCOMPtr.h"
 #include "prmem.h"
 // stuff for temporary root folder hack
 #include "nsIMsgAccountManager.h"
 #include "nsIMsgIncomingServer.h"
 #include "nsIPop3IncomingServer.h"
 #include "nsINoIncomingServer.h"
 #include "nsMsgBaseCID.h"
+#include "nsNativeCharsetUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 
 #include "nsMsgUtils.h"
 #include "nsNetCID.h"
 #include "nsIURIMutator.h"
 
 // it would be really cool to:
@@ -145,18 +146,19 @@ nsLocalURI2Path(const char* rootURI, con
 
   // now ask the server what it's root is
   // and begin pathResult with the mailbox root
   nsCOMPtr<nsIFile> localPath;
   rv = server->GetLocalPath(getter_AddRefs(localPath));
   NS_ENSURE_SUCCESS(rv, rv);
 
 #ifdef XP_WIN
-  // The protocol handler can handle UTF-8 paths even on Windows.
-  nsCString localNativePath = NS_ConvertUTF16toUTF8(localPath->NativePath());
+  nsString path = localPath->NativePath();
+  nsCString localNativePath;
+  NS_CopyUnicodeToNative(path, localNativePath);
 #else
   nsCString localNativePath = localPath->NativePath();
 #endif
   nsEscapeNativePath(localNativePath);
   pathResult = localNativePath.get();
   const char *curPos = uriStr + PL_strlen(rootURI);
   if (curPos) {
     // advance past hostname
--- a/mailnews/local/src/nsMailboxService.cpp
+++ b/mailnews/local/src/nsMailboxService.cpp
@@ -15,16 +15,17 @@
 #include "MailNewsTypes.h"
 #include "nsTArray.h"
 #include "nsLocalUtils.h"
 #include "nsMsgLocalCID.h"
 #include "nsMsgBaseCID.h"
 #include "nsIDocShell.h"
 #include "nsIPop3Service.h"
 #include "nsMsgUtils.h"
+#include "nsNativeCharsetUtils.h"
 #include "nsNetUtil.h"
 #include "nsIDocShellLoadInfo.h"
 #include "nsIWebNavigation.h"
 #include "prprf.h"
 #include "nsIMsgHdr.h"
 #include "nsIFileURL.h"
 #include "mozilla/RefPtr.h"
 
@@ -46,18 +47,19 @@ nsresult nsMailboxService::ParseMailbox(
   nsresult rv;
   nsCOMPtr<nsIMailboxUrl> mailboxurl =
     do_CreateInstance(NS_MAILBOXURL_CONTRACTID, &rv);
   if (NS_SUCCEEDED(rv) && mailboxurl)
   {
     nsCOMPtr<nsIMsgMailNewsUrl> url = do_QueryInterface(mailboxurl);
     // okay now generate the url string
 #ifdef XP_WIN
-    // The protocol handler can handle UTF-8 paths even on Windows.
-    nsCString mailboxPath = NS_ConvertUTF16toUTF8(aMailboxPath->NativePath());
+    nsString path = aMailboxPath->NativePath();
+    nsCString mailboxPath;
+    NS_CopyUnicodeToNative(path, mailboxPath);
 #else
     nsCString mailboxPath = aMailboxPath->NativePath();
 #endif
     nsAutoCString buf;
     MsgEscapeURL(mailboxPath,
                  nsINetUtil::ESCAPE_URL_MINIMAL | nsINetUtil::ESCAPE_URL_FORCED, buf);
     nsEscapeNativePath(buf);
     url->SetUpdatingFolder(true);