From 8545f89b2ff6b0a3398d0f292dd4cf6a982576cd Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Mon, 25 Jul 2016 06:17:17 -0400 Subject: [PATCH] Correctly get the collection/key IDs (fixes #3775) --- ActiveSync/SOGoActiveSyncDispatcher+Sync.m | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m index 06886d343..bb34ca5da 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m +++ b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m @@ -119,7 +119,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. { SOGoCacheGCSObject *o; NSNumber *processIdentifier; - NSString *key; + NSString *key, *collectionId;; int i; processIdentifier = [NSNumber numberWithInt: [[NSProcessInfo processInfo] processIdentifier]]; @@ -139,7 +139,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. for (i = 0; i < [collections count]; i++) { - key = [NSString stringWithFormat: @"SyncRequest+%@", [[[(id)[[collections objectAtIndex: i] getElementsByTagName: @"CollectionId"] lastObject] textValue] stringByUnescapingURL]]; + if ([[collections objectAtIndex: i] isKindOfClass: [NSString class]]) + collectionId = [collections objectAtIndex: i]; + else + collectionId = [[[(id)[[collections objectAtIndex: i] getElementsByTagName: @"CollectionId"] lastObject] textValue] stringByUnescapingURL]; + + key = [NSString stringWithFormat: @"SyncRequest+%@", collectionId]; + [[o properties] setObject: processIdentifier forKey: key]; } } @@ -148,7 +154,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [[o properties] removeObjectForKey: @"SyncRequest"]; for (i = 0; i < [collections count]; i++) { - key = [NSString stringWithFormat: @"SyncRequest+%@", [[[(id)[[collections objectAtIndex: i] getElementsByTagName: @"CollectionId"] lastObject] textValue] stringByUnescapingURL]]; + if ([[collections objectAtIndex: i] isKindOfClass: [NSString class]]) + collectionId = [collections objectAtIndex: i]; + else + collectionId = [[[(id)[[collections objectAtIndex: i] getElementsByTagName: @"CollectionId"] lastObject] textValue] stringByUnescapingURL]; + + key = [NSString stringWithFormat: @"SyncRequest+%@", collectionId]; + [[o properties] removeObjectForKey: key]; } }