From 6d27fdd340a6fd0f4655fd1cc286d14131fcb24b Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Fri, 13 Sep 2019 09:52:04 -0400 Subject: [PATCH] (fix) avoid incorrect truncation leading to exception (fixes #4806) --- ActiveSync/SOGoMailObject+ActiveSync.m | 11 +++++++++++ NEWS | 1 + 2 files changed, 12 insertions(+) diff --git a/ActiveSync/SOGoMailObject+ActiveSync.m b/ActiveSync/SOGoMailObject+ActiveSync.m index b1c27cc98..f9d16c435 100644 --- a/ActiveSync/SOGoMailObject+ActiveSync.m +++ b/ActiveSync/SOGoMailObject+ActiveSync.m @@ -729,6 +729,17 @@ struct GlobalObjectId { break; } + // If we didn't find a "space" character search again for &# to avoid + // truncating the content in the middle of a XML entity + if (i < 0) + { + for (i = len-2 ; i >= 0; i--) + { + if ([theContent characterAtIndex: i] == '&' && [theContent characterAtIndex: i+1] == '#') + break; + } + } + return [theContent substringToIndex: i]; } diff --git a/NEWS b/NEWS index 40974668c..4caf73736 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ Bug fixes - [eas] improve FolderSync operation (#4672) + - [eas] avoid incorrect truncation leading to exception (#4806) 4.0.5 (2018-MM-DD) ------------------