diff --git a/OpenChange/MAPIStoreFallbackContext.m b/OpenChange/MAPIStoreFallbackContext.m index 41463542a..5b1a40ad1 100644 --- a/OpenChange/MAPIStoreFallbackContext.m +++ b/OpenChange/MAPIStoreFallbackContext.m @@ -55,7 +55,10 @@ NSString *baseURL, *url, *name; MAPIStoreUserContext *userContext; - baseURL = [NSString stringWithFormat: @"sogo://%@@fallback/", userName]; + baseURL = [NSString stringWithFormat: @"sogo://%@@fallback/", + [userName stringByReplacingOccurrencesOfString: @"@" + withString: @"%40"]]; + context = talloc_zero (memCtx, struct mapistore_contexts_list); context->url = [baseURL asUnicodeInMemCtx: context]; @@ -99,7 +102,10 @@ forUser: (NSString *) userName { return [NSString stringWithFormat: @"sogo://%@@fallback/0x%.16"PRIx64"/", - userName, (unsigned long long) fid]; + [userName stringByReplacingOccurrencesOfString: @"@" + withString: @"%40"], + (unsigned long long) fid]; + } @end diff --git a/OpenChange/MAPIStoreGCSBaseContext.m b/OpenChange/MAPIStoreGCSBaseContext.m index 216eab01c..384859c5d 100644 --- a/OpenChange/MAPIStoreGCSBaseContext.m +++ b/OpenChange/MAPIStoreGCSBaseContext.m @@ -82,7 +82,9 @@ andTDBIndexing: indexing]; parentFolder = [[userContext rootFolders] objectForKey: moduleName]; baseUrl = [NSString stringWithFormat: @"sogo://%@@%@/", - userName, moduleName]; + [userName stringByReplacingOccurrencesOfString: @"@" + withString: @"%40"], + moduleName]; subfolders = [parentFolder subFolders]; max = [subfolders count]; @@ -127,7 +129,9 @@ if (![parentFolder newFolderWithName: folderName nameInContainer: &nameInContainer]) mapistoreURI = [NSString stringWithFormat: @"sogo://%@@%@/%@/", - userName, moduleName, nameInContainer]; + [userName stringByReplacingOccurrencesOfString: @"@" + withString: @"%40"], + moduleName, nameInContainer]; else mapistoreURI = nil; [MAPIApp setUserContext: nil]; diff --git a/OpenChange/MAPIStoreMailContext.m b/OpenChange/MAPIStoreMailContext.m index 0cddee582..87493ff09 100644 --- a/OpenChange/MAPIStoreMailContext.m +++ b/OpenChange/MAPIStoreMailContext.m @@ -126,7 +126,11 @@ MakeDisplayFolderName (NSString *folderName) trashName = [NSString stringWithFormat: @"folder%@", [unprefixedFolders componentsJoinedByString: @"/folder"]]; - urlBase = [NSString stringWithFormat: @"sogo://%@:%@@mail/", userName, userName]; + urlBase = [NSString stringWithFormat: @"sogo://%@:%@@mail/", + [userName stringByReplacingOccurrencesOfString: @"@" + withString: @"%40"], + [userName stringByReplacingOccurrencesOfString: @"@" + withString: @"%40"]]; for (count = 0; count < 3; count++) { context = talloc_zero (memCtx, struct mapistore_contexts_list); @@ -199,7 +203,10 @@ MakeDisplayFolderName (NSString *folderName) inContainer: accountFolder]; if ([newFolder create]) mapistoreURI = [NSString stringWithFormat: @"sogo://%@:%@@mail/%@/", - userName, userName, + [userName stringByReplacingOccurrencesOfString: @"@" + withString: @"%40"], + [userName stringByReplacingOccurrencesOfString: @"@" + withString: @"%40"], [[folderName stringByEncodingImap4FolderName] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]]; else mapistoreURI = nil; @@ -275,8 +282,12 @@ MakeDisplayFolderName (NSString *folderName) componentsSeparatedByString: @"/"]; folderName = [NSString stringWithFormat: @"folder%@", [unprefixedFolders componentsJoinedByString: @"/folder"]]; - url = [NSString stringWithFormat: @"sogo://%@:%@@outbox/%@", userName, - userName, folderName]; + url = [NSString stringWithFormat: @"sogo://%@:%@@outbox/%@", + [userName stringByReplacingOccurrencesOfString: @"@" + withString: @"%40"], + [userName stringByReplacingOccurrencesOfString: @"@" + withString: @"%40"], + folderName]; context = talloc_zero (memCtx, struct mapistore_contexts_list); context->url = [url asUnicodeInMemCtx: context]; diff --git a/OpenChange/MAPIStoreNotesContext.m b/OpenChange/MAPIStoreNotesContext.m index 594a819b5..725b0d158 100644 --- a/OpenChange/MAPIStoreNotesContext.m +++ b/OpenChange/MAPIStoreNotesContext.m @@ -45,7 +45,8 @@ context = talloc_zero(memCtx, struct mapistore_contexts_list); context->url = talloc_asprintf (context, "sogo://%s@notes/", - [userName UTF8String]); + [[userName stringByReplacingOccurrencesOfString: @"@" + withString: @"%40"] UTF8String]); // context->name = "Notes personnelles"; context->main_folder = true; context->role = MAPISTORE_NOTES_ROLE; diff --git a/OpenChange/MAPIStoreSOGo.m b/OpenChange/MAPIStoreSOGo.m index 923541764..56d9cd4d0 100644 --- a/OpenChange/MAPIStoreSOGo.m +++ b/OpenChange/MAPIStoreSOGo.m @@ -1693,7 +1693,10 @@ sogo_manager_generate_uri (TALLOC_CTX *mem_ctx, username = [NSString stringWithUTF8String: (user ? user : "*")]; /* Do proper directory lookup here */ directory = [NSString stringWithUTF8String: (folder ? folder : "*")]; - partialURLString = [NSString stringWithFormat: @"sogo://%@:*@%@", username, directory]; + partialURLString = [NSString stringWithFormat: @"sogo://%@:*@%@", + [username stringByReplacingOccurrencesOfString: @"@" + withString: @"%40"], + directory]; } if (![partialURLString hasSuffix: @"/"]) partialURLString = [partialURLString stringByAppendingString: @"/"];