From 0e8bf0d2390c848154de4f9c9fa864b7c4b03002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20J=2E=20Hern=C3=A1ndez=20Blasco?= Date: Mon, 26 Jan 2015 15:55:22 +0100 Subject: [PATCH] oc-mail: Move mail folders with reserved chars The URL was incorrectly set when any of ;/?:@&=+$,# was used in the folder name. We have to mimetise what it is done in createFolder message selector. That is, perform the IMAP4 encoding + URL encoding without CSS encoding. The IMAP4 + CSS encoding (without URL encoding) is used to store the folder in SOGo and OpenChange Indexing database as we do right now. --- OpenChange/MAPIStoreMailFolder.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/OpenChange/MAPIStoreMailFolder.m b/OpenChange/MAPIStoreMailFolder.m index 57679c1f1..5c93e11d2 100644 --- a/OpenChange/MAPIStoreMailFolder.m +++ b/OpenChange/MAPIStoreMailFolder.m @@ -1217,7 +1217,7 @@ _parseCOPYUID (NSString *line, NSArray **destUIDsP) NGImap4Connection *connection; NGImap4Client *client; NSString *newURL, *parentDBFolderPath, *childKey, *folderIMAPName, - *urlNamePart, *newFolderIMAPName; + *urlNamePart, *newFolderIMAPName, *newFolderDBName; NSException *error; MAPIStoreMapping *mapping; NSDictionary *result; @@ -1230,7 +1230,8 @@ _parseCOPYUID (NSString *line, NSArray **destUIDsP) targetSOGoFolder = [targetFolder sogoObject]; if (isMove) { - urlNamePart = [newFolderName stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; + /* Mimetise [SOGoMailFolderK imap4URLString] */ + urlNamePart = [[newFolderName stringByEncodingImap4FolderName] stringByEscapingURL]; newFolderURL = [NSURL URLWithString: urlNamePart relativeToURL: [targetSOGoFolder imap4URL]]; error = [[sogoObject imap4Connection] @@ -1242,8 +1243,9 @@ _parseCOPYUID (NSString *line, NSArray **destUIDsP) { rc = MAPISTORE_SUCCESS; mapping = [self mapping]; + newFolderDBName = [[newFolderName stringByEncodingImap4FolderName] asCSSIdentifier]; newURL = [NSString stringWithFormat: @"%@folder%@/", - [targetFolder url], urlNamePart]; + [targetFolder url], newFolderDBName]; [mapping updateID: [self objectId] withURL: newURL]; parentDBFolderPath = [[targetFolder dbFolder] path]; if (!parentDBFolderPath) @@ -1251,7 +1253,7 @@ _parseCOPYUID (NSString *line, NSArray **destUIDsP) [dbFolder changePathTo: [NSString stringWithFormat: @"%@/folder%@", parentDBFolderPath, - newFolderName]]; + newFolderDBName]]; } } else