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.