Bug 1404003 - Bug 1402750 follow-up: char16_t triggers undesired RFind(). r=aceman
authorJorg K <jorgk@jorgk.com>
Sat, 30 Sep 2017 23:17:20 +0200
changeset 22236 079662f3683788017ec3c4f605863681c5e2d0e2
parent 22235 3c0dde60442ecc04dd4af8b32593a764c494e950
child 22237 94a4ec7dff4b517377987f5ebf4e2b690fbc4e97
push id13567
push usermozilla@jorgk.com
push dateSat, 30 Sep 2017 21:23:54 +0000
treeherdercomm-central@079662f36837 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman
bugs1404003, 1402750
Bug 1404003 - Bug 1402750 follow-up: char16_t triggers undesired RFind(). r=aceman
mailnews/base/public/msgCore.h
mailnews/base/util/nsMsgDBFolder.cpp
mailnews/base/util/nsMsgUtils.cpp
mailnews/imap/src/nsImapMailFolder.cpp
--- a/mailnews/base/public/msgCore.h
+++ b/mailnews/base/public/msgCore.h
@@ -20,16 +20,17 @@ class nsIMsgFolder;
 // include common interfaces such as the service manager and the repository....
 #include "nsIServiceManager.h"
 #include "nsIComponentManager.h"
 
 /*
  * The suffix we use for the mail summary file.
  */
 #define SUMMARY_SUFFIX u".msf"
+#define SUMMARY_SUFFIX8 ".msf"
 
 /*
  * The suffix we use for folder subdirectories.
  */
 #define FOLDER_SUFFIX u".sbd"
 #define FOLDER_SUFFIX8 ".sbd"
 
 /*
--- a/mailnews/base/util/nsMsgDBFolder.cpp
+++ b/mailnews/base/util/nsMsgDBFolder.cpp
@@ -4716,17 +4716,17 @@ NS_IMETHODIMP nsMsgDBFolder::GetSummaryF
   NS_ENSURE_SUCCESS(rv, rv);
 
   newSummaryLocation->InitWithFile(pathFile);
 
   nsString fileName;
   rv = newSummaryLocation->GetLeafName(fileName);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  fileName.Append(NS_LITERAL_STRING(SUMMARY_SUFFIX));
+  fileName.AppendLiteral(SUMMARY_SUFFIX);
   rv = newSummaryLocation->SetLeafName(fileName);
   NS_ENSURE_SUCCESS(rv, rv);
 
   newSummaryLocation.forget(aSummaryFile);
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/mailnews/base/util/nsMsgUtils.cpp
+++ b/mailnews/base/util/nsMsgUtils.cpp
@@ -1344,17 +1344,17 @@ nsresult GetSummaryFileLocation(nsIFile*
 
   newSummaryLocation->InitWithFile(fileLocation);
   nsString fileName;
 
   rv = newSummaryLocation->GetLeafName(fileName);
   if (NS_FAILED(rv))
     return rv;
 
-  fileName.Append(NS_LITERAL_STRING(SUMMARY_SUFFIX));
+  fileName.AppendLiteral(SUMMARY_SUFFIX);
   rv = newSummaryLocation->SetLeafName(fileName);
   NS_ENSURE_SUCCESS(rv, rv);
 
   newSummaryLocation.forget(summaryLocation);
   return NS_OK;
 }
 
 void MsgGenerateNowStr(nsACString &nowStr)
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -247,17 +247,20 @@ nsresult nsImapMailFolder::AddDirectoryS
 
   return NS_OK;
 }
 
 static bool
 nsShouldIgnoreFile(nsString& name)
 {
   int32_t len = name.Length();
-  if (len > 4 && name.RFind(SUMMARY_SUFFIX, true) == len - 4)
+  // Warning: The first argument of RFind() needs to be a char string here so
+  // that the second argument means 'ignorecase'. When passing a char16_t here,
+  // a different overload is triggered and the argument is interpreted as offset.
+  if (len > 4 && name.RFind(SUMMARY_SUFFIX8, true) == len - 4)
   {
     name.SetLength(len-4); // truncate the string
     return false;
   }
   return true;
 }
 
 nsresult nsImapMailFolder::CreateChildFromURI(const nsCString &uri, nsIMsgFolder **folder)