From 5d43513dd9f36dd47610c822bee3ace20e91aae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Juli=C3=A1n?= Date: Thu, 12 Jun 2014 15:46:02 +0200 Subject: [PATCH] Removing some trail characters at event description * They are sometimes present after a \r\n\n --- OpenChange/MAPIStoreAppointmentWrapper.m | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/OpenChange/MAPIStoreAppointmentWrapper.m b/OpenChange/MAPIStoreAppointmentWrapper.m index 5445f989c..c07998c5e 100644 --- a/OpenChange/MAPIStoreAppointmentWrapper.m +++ b/OpenChange/MAPIStoreAppointmentWrapper.m @@ -1214,11 +1214,27 @@ static NSCharacterSet *hexCharacterSet = nil; return MAPISTORE_SUCCESS; } +/* +private static function parseDescriptionOc2Rc($description) +{ + $description = ltrim($description, ')'); + + if (strpos($description, "\r\n\n") !== false) { + $exploded = explode("\r\n\n", $description, -1); + $description = join($exploded, "\n"); + } + + return $description; +} +*/ + - (int) getPidTagBody: (void **) data inMemCtx: (TALLOC_CTX *) memCtx { int rc; + NSRange range; NSString *stringValue; + NSString *trimingString = @"\r\n\n"; /* FIXME: there is a confusion in NGCards around "comment" and "description" */ stringValue = [event comment]; @@ -1226,6 +1242,14 @@ static NSCharacterSet *hexCharacterSet = nil; && ![stringValue isEqualToString: @"\r\n"] && ![stringValue isEqualToString: @"\n"]) { + /* Avoiding those trail weird characters at event description */ + range = [stringValue rangeOfString: trimingString + options: NSBackwardsSearch]; + if (range.location > 0) + { + stringValue = [stringValue substringToIndex: (NSMaxRange(range) -1)]; + } + rc = MAPISTORE_SUCCESS; *data = [stringValue asUnicodeInMemCtx: memCtx]; }