Bug 1270651 - fix deletion of AB cards after search. r=rkent a=rkent THUNDERBIRD452b1_2016051723_RELBRANCH
authoraceman <acelists@atlas.sk>
Fri, 13 May 2016 07:20:40 +0200
branchTHUNDERBIRD452b1_2016051723_RELBRANCH
changeset 27119 742502786eb96c18c2c9d41458e35bc6c7af5255
parent 27118 79d6facfe3da6af2b9fe3037b6ad127377eedb42
child 27120 6aebfedc330d1947e31b827fb7e77fdb9331cce3
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent, rkent
bugs1270651
Bug 1270651 - fix deletion of AB cards after search. r=rkent a=rkent
mailnews/addrbook/src/nsAbMDBDirectory.cpp
--- a/mailnews/addrbook/src/nsAbMDBDirectory.cpp
+++ b/mailnews/addrbook/src/nsAbMDBDirectory.cpp
@@ -48,34 +48,39 @@ NS_IMPL_ISUPPORTS_INHERITED(nsAbMDBDirec
                              nsIAbDirectorySearch,
                              nsIAddrDBListener)
 
 NS_IMETHODIMP nsAbMDBDirectory::Init(const char *aUri)
 {
   // We need to ensure  that the m_DirPrefId is initialized properly
   nsDependentCString uri(aUri);
 
-  if (uri.Find("MailList") != -1)
+  // Find the first ? (of the search params) if there is one.
+  // We know we can start at the end of the moz-abmdbdirectory:// because
+  // that's the URI we should have been passed.
+  int32_t searchCharLocation = uri.FindChar('?', kMDBDirectoryRootLen);
+  nsAutoCString URINoQuery;
+  if (searchCharLocation != kNotFound)
+  {
+    URINoQuery = Substring(uri, 0, searchCharLocation);
+  } else {
+    URINoQuery.Assign(uri);
+  }
+
+  // In the non-query part of the URI, check if we are a mailinglist
+  if (URINoQuery.Find("MailList") != kNotFound)
     m_IsMailList = true;
 
   // Mailing lists don't have their own prefs.
   if (m_DirPrefId.IsEmpty() && !m_IsMailList)
   {
-    // Find the first ? (of the search params) if there is one.
-    // We know we can start at the end of the moz-abmdbdirectory:// because
-    // that's the URI we should have been passed.
-    int32_t searchCharLocation = uri.FindChar('?', kMDBDirectoryRootLen);
-
     nsAutoCString filename;
 
-    // extract the filename from the uri.
-    if (searchCharLocation == -1)
-      filename = Substring(uri, kMDBDirectoryRootLen);
-    else
-      filename = Substring(uri, kMDBDirectoryRootLen, searchCharLocation - kMDBDirectoryRootLen);
+    // Extract the filename from the uri.
+    filename = Substring(URINoQuery, kMDBDirectoryRootLen);
 
     // Get the pref servers and the address book directory branch
     nsresult rv;
     nsCOMPtr<nsIPrefService> prefService(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIPrefBranch> prefBranch;
     rv = prefService->GetBranch(NS_LITERAL_CSTRING(PREF_LDAP_SERVER_TREE_NAME ".").get(),