merge of '22f4b6731e332b6ef213a0c2e104ac7fef48969a'

and 'e2f910a1982b774a3f5dfd586d968821441f2076'

Monotone-Parent: 22f4b6731e332b6ef213a0c2e104ac7fef48969a
Monotone-Parent: e2f910a1982b774a3f5dfd586d968821441f2076
Monotone-Revision: 572391072fa416635b9921d39ed76478ed762097

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2012-08-17T17:57:01
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2012-08-17 17:57:01 +00:00
commit 73d14bee9e
5 changed files with 32 additions and 17 deletions

View File

@ -1,3 +1,9 @@
2012-08-17 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreContext.m (-getPath:ofFMID:inMemCtx:):
properly escape urls containing non-ascii chars.
(-getRootFoldeR:withFID:): idem.
2012-08-16 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* OpenChange/MAPIStoreCalendarMessage.m

View File

@ -366,7 +366,8 @@ static inline NSURL *CompleteURLFromMapistoreURI (const char *uri)
NSString *objectURL, *url;
// TDB_DATA key, dbuf;
url = [contextUrl absoluteString];
url = [[contextUrl absoluteString]
stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
objectURL = [[userContext mapping] urlFromID: fmid];
if (objectURL)
{
@ -417,15 +418,18 @@ static inline NSURL *CompleteURLFromMapistoreURI (const char *uri)
MAPIStoreFolder *baseFolder;
SOGoFolder *currentFolder;
WOContext *woContext;
NSString *path;
NSString *path, *urlString;
NSArray *pathComponents;
NSUInteger count, max;
mapping = [userContext mapping];
if (![mapping urlFromID: newFid])
[mapping registerURL: [contextUrl absoluteString]
withID: newFid];
{
urlString = [[contextUrl absoluteString]
stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
[mapping registerURL: urlString
withID: newFid];
}
[userContext activateWithUser: activeUser];
woContext = [userContext woContext];

View File

@ -94,12 +94,14 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
{
NSURL *folderURL;
NSMutableString *pathPrefix;
NSString *path, *folderName;
NSString *path, *escapedURL, *folderName;
NSArray *parts;
NSUInteger lastPartIdx;
MAPIStoreUserContext *userContext;
folderURL = [NSURL URLWithString: [self url]];
escapedURL = [[self url]
stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
folderURL = [NSURL URLWithString: escapedURL];
path = [folderURL path];
path = [path substringFromIndex: 1];
if ([path length] > 0)
@ -1495,7 +1497,8 @@ Class NSExceptionK, MAPIStoreFAIMessageK, MAPIStoreMessageTableK, MAPIStoreFAIMe
url = [NSString stringWithFormat: @"%@/", [super url]];
else
{
url = [[context url] absoluteString];
url = [[[context url] absoluteString]
stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
if (![url hasSuffix: @"/"])
url = [NSString stringWithFormat: @"%@/", url];
}

View File

@ -206,12 +206,14 @@ MakeDisplayFolderName (NSString *folderName)
- (void) updateURLWithFolderName: (NSString *) newFolderName
{
NSString *urlString;
NSString *urlString, *escapedName;
NSMutableArray *pathComponents;
BOOL hasSlash;
NSUInteger max, folderNameIdx;
NSURL *newURL;
/* we do not need to unescape the url here as it will be reassembled later
in the method */
urlString = [contextUrl absoluteString];
hasSlash = [urlString hasSuffix: @"/"];
pathComponents = [[urlString componentsSeparatedByString: @"/"]
@ -222,8 +224,9 @@ MakeDisplayFolderName (NSString *folderName)
folderNameIdx = max - 2;
else
folderNameIdx = max - 1;
escapedName = [newFolderName stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
[pathComponents replaceObjectAtIndex: folderNameIdx
withObject: [newFolderName stringByEscapingURL]];
withObject: escapedName];
urlString = [pathComponents componentsJoinedByString: @"/"];
newURL = [NSURL URLWithString: urlString];
ASSIGN (contextUrl, newURL);

View File

@ -1046,15 +1046,15 @@ _parseCOPYUID (NSString *line, NSArray **destUIDsP)
folderURL = [sogoObject imap4URL];
if (!newFolderName)
newFolderName = [sogoObject displayName];
newFolderName = [newFolderName stringByEscapingURL];
targetSOGoFolder = [targetFolder sogoObject];
newFolderURL = [NSURL URLWithString: newFolderName
relativeToURL: [targetSOGoFolder imap4URL]];
if (isMove)
{
newFolderURL = [NSURL
URLWithString: [newFolderName stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]
relativeToURL: [targetSOGoFolder imap4URL]];
error = [[sogoObject imap4Connection]
moveMailboxAtURL: folderURL
toURL: newFolderURL];
moveMailboxAtURL: folderURL
toURL: newFolderURL];
if (error)
rc = MAPISTORE_ERR_DENIED;
else
@ -1063,8 +1063,7 @@ _parseCOPYUID (NSString *line, NSArray **destUIDsP)
mapping = [self mapping];
newURL = [NSString stringWithFormat: @"%@folder%@/",
[targetFolder url], newFolderName];
[mapping updateID: [self objectId]
withURL: newURL];
[mapping updateID: [self objectId] withURL: newURL];
parentDBFolderPath = [[targetFolder dbFolder] path];
if (!parentDBFolderPath)
parentDBFolderPath = @"";