From f5f66d0b74d9a7895db3cfb138830d0cb7b46429 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 12 Jun 2012 14:41:51 +0000 Subject: [PATCH] Monotone-Parent: d537d152064e4fd06ac7b263bf3d3b3738715291 Monotone-Revision: ea6bc80cdabf55c83e6df32dd1aaa4ecfa16a6e1 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-06-12T14:41:51 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 7 +++++++ SoObjects/SOGo/SOGoGroup.m | 23 +++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c677dca0..0dcca9839 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-06-12 Wolfgang Sourdeau + + * SoObjects/SOGo/SOGoGroup.m + (+groupWithValue:andSourceSelector:inDomain:): handle the case + the value of "objectclass" is actually an NSString instance, + otherwise causing a crash with the NSArray methods. + 2012-06-04 Francis Lachapelle * UI/WebServerResources/UIxFilterEditor.js (savePreferences): diff --git a/SoObjects/SOGo/SOGoGroup.m b/SoObjects/SOGo/SOGoGroup.m index 3d9a9a702..1718ccdf2 100644 --- a/SoObjects/SOGo/SOGoGroup.m +++ b/SoObjects/SOGo/SOGoGroup.m @@ -170,13 +170,24 @@ if (classes) { - int i, c; + /* LDAP records returned as dictionaries may contain NSString or + NSArray values, depending on whether the amount of values + assigned to a key is 1 or more. Since this can occur with + "objectclass" too, we need to check whether "classes" is actually + an NSString instance... */ + if ([classes isKindOfClass: [NSString class]]) + classes = [NSArray arrayWithObject: + [(NSString *) classes lowercaseString]]; + else + { + int i, c; - classes = [NSMutableArray arrayWithArray: classes]; - c = [classes count]; - for (i = 0; i < c; i++) - [(id)classes replaceObjectAtIndex: i - withObject: [[classes objectAtIndex: i] lowercaseString]]; + classes = [NSMutableArray arrayWithArray: classes]; + c = [classes count]; + for (i = 0; i < c; i++) + [(id)classes replaceObjectAtIndex: i + withObject: [[classes objectAtIndex: i] lowercaseString]]; + } } // Found a group, let's return it.