From ea86f136b757a0668d2aabe8e533547f81a9bd23 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Fri, 24 Jan 2014 14:10:19 -0500 Subject: [PATCH] Properly escape folder/file names and fixed date representation in emails --- ActiveSync/NSString+ActiveSync.m | 2 +- ActiveSync/SOGoActiveSyncDispatcher.m | 8 ++++---- ActiveSync/SOGoMailObject+ActiveSync.m | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ActiveSync/NSString+ActiveSync.m b/ActiveSync/NSString+ActiveSync.m index 6b966e181..5f4fbe799 100644 --- a/ActiveSync/NSString+ActiveSync.m +++ b/ActiveSync/NSString+ActiveSync.m @@ -73,7 +73,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. else { // mail/ - realCollectionId = [self substringFromIndex: 5]; + realCollectionId = [[self stringByUnescapingURL] substringFromIndex: 5]; *folderType = ActiveSyncMailFolder; } diff --git a/ActiveSync/SOGoActiveSyncDispatcher.m b/ActiveSync/SOGoActiveSyncDispatcher.m index ce3793ec7..6c0cc5adb 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher.m +++ b/ActiveSync/SOGoActiveSyncDispatcher.m @@ -455,8 +455,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } [s appendFormat: @"%@%@%d%@", - serverId, - parentId, + [serverId stringByEscapingURL], + [parentId stringByEscapingURL], type, name]; } @@ -606,7 +606,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOGoMicrosoftActiveSyncFolderType folderType; - fileReference = [[(id)[theDocumentElement getElementsByTagName: @"FileReference"] lastObject] textValue]; + fileReference = [[[(id)[theDocumentElement getElementsByTagName: @"FileReference"] lastObject] textValue] stringByUnescapingURL]; realCollectionId = [fileReference realCollectionIdWithFolderType: &folderType]; @@ -649,7 +649,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [s appendString: @""]; [s appendString: @"1"]; - [s appendFormat: @"%@", fileReference]; + [s appendFormat: @"%@", [fileReference stringByEscapingURL]]; [s appendString: @""]; [s appendFormat: @"%@/%@", [[currentBodyPart partInfo] objectForKey: @"type"], [[currentBodyPart partInfo] objectForKey: @"subtype"]]; diff --git a/ActiveSync/SOGoMailObject+ActiveSync.m b/ActiveSync/SOGoMailObject+ActiveSync.m index 7e44d28a3..e00b31724 100644 --- a/ActiveSync/SOGoMailObject+ActiveSync.m +++ b/ActiveSync/SOGoMailObject+ActiveSync.m @@ -226,7 +226,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // DateReceived value = [self date]; if (value) - [s appendFormat: @"%@", [value activeSyncRepresentation]]; + [s appendFormat: @"%@", [value activeSyncRepresentationWithoutSeparators]]; // Importance - FIXME [s appendFormat: @"%@", @"1"]; @@ -338,7 +338,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // FileReference must be a unique identifier across the whole store. We use the following structure: // mail// // mail/INBOX/2 - [s appendFormat: @"mail/%@/%@/%@", [[self container] relativeImap4Name], [self nameInContainer], [value objectForKey: @"path"]]; + [s appendFormat: @"mail/%@/%@/%@", [[[self container] relativeImap4Name] stringByEscapingURL], [self nameInContainer], [value objectForKey: @"path"]]; [s appendFormat: @"%d", 1]; // See: http://msdn.microsoft.com/en-us/library/ee160322(v=exchg.80).aspx [s appendFormat: @"%d", [[value objectForKey: @"size"] intValue]]; @@ -369,7 +369,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. nativeBodyType = 1; [s appendFormat: @"%d", nativeBodyType]; - + return s; }