From a338b193ba0078d0a858b431d43f2e251fb29651 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 17 Sep 2014 19:45:44 -0400 Subject: [PATCH] Fix for bug #2838 --- .../Appointments/SOGoAppointmentFolders.m | 57 +++++++++++++++++-- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentFolders.m b/SoObjects/Appointments/SOGoAppointmentFolders.m index f5ae1b23c..10361c006 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolders.m +++ b/SoObjects/Appointments/SOGoAppointmentFolders.m @@ -33,6 +33,8 @@ #import +#import +#import #import #import @@ -58,6 +60,40 @@ static SoSecurityManager *sm = nil; +@interface NGDOMElement (SOGo) + +- (BOOL) isTextNode; + +@end + +@implementation NGDOMElement (SOGo) + +- (BOOL) isTextNode +{ + id children; + id element; + int i; + + if ([self nodeType] == DOM_TEXT_NODE) + return YES; + + children = [self childNodes]; + + for (i = 0; i < [children length]; i++) + { + element = [children objectAtIndex: i]; + + if ([element nodeType] != DOM_TEXT_NODE) + return NO; + } + + return YES; +} + +@end + + + @implementation SOGoAppointmentFolders + (void) initialize @@ -307,10 +343,17 @@ static SoSecurityManager *sm = nil; [currentElement nodeName]]; if ([currentName isEqualToString: propertyName]) { - values = [currentElement childNodes]; - if ([values length]) - property = [[values objectAtIndex: 0] nodeValue]; - } + if ([(id)currentElement isTextNode]) + { + property = [(id)currentElement textValue]; + } + else + { + values = [currentElement childNodes]; + if ([values length]) + property = [[values objectAtIndex: 0] nodeValue]; + } + } } return property; @@ -333,7 +376,11 @@ static SoSecurityManager *sm = nil; values = [currentProperty childNodes]; if ([values length]) { - value = [[values objectAtIndex: 0] nodeValue]; + if ([(id)currentProperty isTextNode]) + value = [(id)currentProperty textValue]; + else + value = [[values objectAtIndex: 0] nodeValue]; + currentName = [NSString stringWithFormat: @"{%@}%@", [currentProperty namespaceURI], [currentProperty nodeName]];