Bug 453698 - "nsAbLDAPCard::SetMetaProperties assumes an entry has at least one objectClass" [r=Standard8 sr=bienvenu]
authorJosh Geenen <joshgeenen+bugzilla@gmail.com>
Thu, 11 Sep 2008 16:11:14 +0100
changeset 315 c58a10a0b2629adf19dbe805d050c2b2a1d7e498
parent 314 8c88e8720ad78d920ad890f7107e5ecc5dea5c22
child 316 fafe040dd06d014de3b01ed05dd6a41da75d0fd2
push id1
push userhg
push dateTue, 08 Jul 2014 14:20:55 +0000
treeherdercomm-esr31@1665b2be5642 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, bienvenu
bugs453698
Bug 453698 - "nsAbLDAPCard::SetMetaProperties assumes an entry has at least one objectClass" [r=Standard8 sr=bienvenu]
mailnews/addrbook/src/nsAbLDAPCard.cpp
--- a/mailnews/addrbook/src/nsAbLDAPCard.cpp
+++ b/mailnews/addrbook/src/nsAbLDAPCard.cpp
@@ -44,16 +44,17 @@
 #include "nsILDAPModification.h"
 #include "nsILDAPBERValue.h"
 #include "nsILDAPMessage.h"
 #include "nsIAbLDAPAttributeMap.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsAbBaseCID.h"
 #include "nsAbUtils.h"
+#include "nsILDAPErrors.h"
 
 #include <stdio.h>
 
 #define kDNColumn "DN"
 
 nsAbLDAPCard::nsAbLDAPCard()
 {
 }
@@ -298,23 +299,30 @@ NS_IMETHODIMP nsAbLDAPCard::SetMetaPrope
   for (PRUint32 i = 0; i < attrs.GetSize(); ++i)
   {
     attr.Assign(nsDependentCString(attrs[i]));
     ToLowerCase(attr);
     m_attributes.AppendCString(attr);
   }
 
   // Get the objectClass values
+  m_objectClass.Clear();
   PRUnicharPtrArrayGuard vals;
   rv = aMessage->GetValues("objectClass", vals.GetSizeAddr(),
     vals.GetArrayAddr());
+
+  // objectClass is not always included in search result entries and
+  // nsILDAPMessage::GetValues returns NS_ERROR_LDAP_DECODING_ERROR if the
+  // requested attribute doesn't exist.
+  if (rv ==  NS_ERROR_LDAP_DECODING_ERROR)
+    return NS_OK;
+
   NS_ENSURE_SUCCESS(rv, rv);
   
   nsCAutoString oclass;
-  m_objectClass.Clear();
   for (PRUint32 i = 0; i < vals.GetSize(); ++i)
   {
     oclass.Assign(NS_LossyConvertUTF16toASCII(nsDependentString(vals[i])));
     ToLowerCase(oclass);
     m_objectClass.AppendCString(oclass);
   }
 
   return NS_OK;