openchange: return proper url for folders with non-ascii chars
toManyRelationshipKeysWithNamespaces applies asCSSIdentifier function to the names which are already "Imap4Encoded". So we need to remove the CSSIdentifier function first and then "Imap4Decode" to get the real name. Once we have the real name, to create the url we have to use the same logic as the function that creates the folder and creates this url for the first time (this function is createRootSecondaryFolderWithFID) which is to apply, in this order: - asCSSIdentifier - stringByEncodingImap4FolderName - stringByAddingPercentEscapesUsingEncoding
This commit is contained in:
parent
f1d14fdeca
commit
68c38e2b5c
|
@ -87,7 +87,7 @@ MakeDisplayFolderName (NSString *folderName)
|
||||||
inMemCtx: (TALLOC_CTX *) memCtx
|
inMemCtx: (TALLOC_CTX *) memCtx
|
||||||
{
|
{
|
||||||
struct mapistore_contexts_list *firstContext = NULL, *context;
|
struct mapistore_contexts_list *firstContext = NULL, *context;
|
||||||
NSString *urlBase, *stringData, *currentName, *inboxName, *draftsName, *sentName, *trashName;
|
NSString *urlBase, *stringData, *currentName, *realName, *inboxName, *draftsName, *sentName, *trashName;
|
||||||
NSArray *unprefixedFolders;
|
NSArray *unprefixedFolders;
|
||||||
NSMutableArray *secondaryFolders;
|
NSMutableArray *secondaryFolders;
|
||||||
enum mapistore_context_role role[] = {MAPISTORE_MAIL_ROLE,
|
enum mapistore_context_role role[] = {MAPISTORE_MAIL_ROLE,
|
||||||
|
@ -153,12 +153,23 @@ MakeDisplayFolderName (NSString *folderName)
|
||||||
for (count = 0; count < max; count++)
|
for (count = 0; count < max; count++)
|
||||||
{
|
{
|
||||||
context = talloc_zero (memCtx, struct mapistore_contexts_list);
|
context = talloc_zero (memCtx, struct mapistore_contexts_list);
|
||||||
|
// secondaryFolders has the names (1) Imap4Encoded and (2) asCSSIdentifier
|
||||||
|
// e.g.: Probl&AOg-mes_SP_de_SP_synchronisation
|
||||||
currentName = [secondaryFolders objectAtIndex: count];
|
currentName = [secondaryFolders objectAtIndex: count];
|
||||||
stringData = [NSString stringWithFormat: @"%@%@",
|
// To get the real name we have to revert that (applying the decode functions)
|
||||||
urlBase, [currentName stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
|
// in reverse order
|
||||||
context->url = [stringData asUnicodeInMemCtx: context];
|
// e.g.: Problèmes de synchronisation
|
||||||
stringData = [[[currentName substringFromIndex: 6] fromCSSIdentifier] stringByDecodingImap4FolderName];
|
realName = [[currentName fromCSSIdentifier]
|
||||||
context->name = [stringData asUnicodeInMemCtx: context];
|
stringByDecodingImap4FolderName];
|
||||||
|
// And finally to represent that as URI we have to (1) asCSSIdentifier,
|
||||||
|
// (2) Imap4Encode and (3) AddPercentEscapes
|
||||||
|
// e.g.: Probl&AOg-mes_SP_de_SP_synchronisation
|
||||||
|
// In the example there are no percent escapes added because is already ok
|
||||||
|
stringData = [[[realName asCSSIdentifier]
|
||||||
|
stringByEncodingImap4FolderName]
|
||||||
|
stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
|
||||||
|
context->url = [[NSString stringWithFormat: @"%@%@", urlBase, stringData] asUnicodeInMemCtx: context];
|
||||||
|
context->name = [[realName substringFromIndex: 6] asUnicodeInMemCtx: context];
|
||||||
context->main_folder = false;
|
context->main_folder = false;
|
||||||
context->role = MAPISTORE_MAIL_ROLE;
|
context->role = MAPISTORE_MAIL_ROLE;
|
||||||
context->tag = "tag";
|
context->tag = "tag";
|
||||||
|
|
Loading…
Reference in a new issue