(web) Fix renaming a mailbox with special chars

This commit is contained in:
Francis Lachapelle
2017-04-12 13:41:24 -04:00
parent 5570d28d12
commit 8bcda19799
2 changed files with 22 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
/*
Copyright (C) 2009-2014 Inverse inc.
Copyright (C) 2009-2017 Inverse inc.
Copyright (C) 2004-2005 SKYRIX Software AG
This file is part of SOGo.
@@ -295,15 +295,15 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data)
return filenames;
}
- (NSException *) renameTo: (NSString *) newName
- (NSException *) renameTo: (NSString *) theNewName
{
NSException *error;
SOGoMailFolder *inbox;
NSURL *destURL;
NSString *path;
NSString *path, *newName;
NGImap4Client *client;
if ([newName length] > 0)
if ([theNewName length] > 0)
{
[self imap4URL];
@@ -318,17 +318,19 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data)
if (![path hasSuffix: @"/"])
path = [path stringByAppendingString: @"/"];
newName = [theNewName stringByEncodingImap4FolderName];
// If new name contains the path - dont't need to add
if ([newName rangeOfString: @"/"].location == NSNotFound)
destURL = [[NSURL alloc] initWithScheme: [imap4URL scheme]
host: [imap4URL host]
path: [NSString stringWithFormat: @"%@%@",
path, [newName stringByEncodingImap4FolderName]]];
path, newName]];
else
destURL = [[NSURL alloc] initWithScheme: [imap4URL scheme]
host: [imap4URL host]
path: [NSString stringWithFormat: @"%@",
[newName stringByEncodingImap4FolderName]]];
newName]];
[destURL autorelease];
error = [imap4 moveMailboxAtURL: imap4URL
toURL: destURL];

View File

@@ -1,6 +1,6 @@
/* UIxMailFolderActions.m - this file is part of SOGo
*
* Copyright (C) 2007-2016 Inverse inc.
* Copyright (C) 2007-2017 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,6 +35,7 @@
#import <SOGo/NSObject+Utilities.h>
#import <SOGo/NSString+Utilities.h>
#import <SOGo/SOGoDomainDefaults.h>
#import <SOGo/SOGoSystemDefaults.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserSettings.h>
@@ -106,6 +107,7 @@
* @apiParam {String} name Name of the mailbox
*
* @apiSuccess (Success 200) {String} path New mailbox path relative to account
* @apiSuccess (Success 200) {String} sievePath New mailbox path relative to account for Sieve script usage
* @apiError (Error 500) {Object} error The error message
*/
- (WOResponse *) renameFolderAction
@@ -115,7 +117,8 @@
WORequest *request;
WOResponse *response;
NSException *error;
NSString *newFolderName, *newFolderPath, *currentMailbox, *currentAccount, *keyForMsgUIDs, *newKeyForMsgUIDs;
NSString *newFolderName, *newFolderPath, *sievePath, *currentMailbox, *currentAccount,
*keyForMsgUIDs, *newKeyForMsgUIDs;
NSMutableDictionary *params, *moduleSettings, *threadsCollapsed, *message;
NSArray *values;
@@ -164,8 +167,15 @@
}
}
newFolderPath = [[[co imap4URL] path] substringFromIndex: 1]; // remove slash at beginning of path
message = [NSDictionary dictionaryWithObject: newFolderPath
forKey: @"path"];
NSString *sieveFolderEncoding = [[SOGoSystemDefaults sharedSystemDefaults] sieveFolderEncoding];
if ([sieveFolderEncoding isEqualToString: @"UTF-8"])
sievePath = [newFolderPath stringByDecodingImap4FolderName];
else
sievePath = newFolderPath;
message = [NSDictionary dictionaryWithObjectsAndKeys:
newFolderPath, @"path", sievePath, @"sievePath", nil];
response = [self responseWithStatus: 200 andJSONRepresentation: message];
}
}