diff --git a/OpenChange/MAPIStoreMapping.m b/OpenChange/MAPIStoreMapping.m index 8c7e29090..36c4dc9a3 100644 --- a/OpenChange/MAPIStoreMapping.m +++ b/OpenChange/MAPIStoreMapping.m @@ -30,6 +30,8 @@ #import +#import + #import "MAPIStoreTypes.h" #import "MAPIStoreMapping.h" @@ -209,13 +211,10 @@ MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2, { NSArray *allKeys; NSUInteger count, max; - NSString *currentKey, *keyEnd, *newKey; - NSUInteger oldURLLength; + NSString *currentKey, *newKey; NSNumber *idKey; TDB_DATA key, dbuf; - oldURLLength = [oldURL length]; - allKeys = [reverseMapping allKeys]; max = [allKeys count]; for (count = 0; count < max; count++) @@ -223,8 +222,8 @@ MAPIStoreMappingTDBTraverse (TDB_CONTEXT *ctx, TDB_DATA data1, TDB_DATA data2, currentKey = [allKeys objectAtIndex: count]; if ([currentKey hasPrefix: oldURL]) { - keyEnd = [currentKey substringFromIndex: oldURLLength]; - newKey = [NSString stringWithFormat: @"%@%@", urlString, keyEnd]; + newKey = [currentKey stringByReplacingPrefix: oldURL + withPrefix: urlString]; idKey = [reverseMapping objectForKey: currentKey]; [mapping setObject: newKey forKey: idKey];