aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDatabaseDocument.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-06-26 23:11:25 +0000
committerrowanbeentje <rowan@beent.je>2012-06-26 23:11:25 +0000
commite0be0f0668619e4fb70e23d8e25b2680f12b6a12 (patch)
tree5aa01b394f34657e35391a0b146a33ffb7b40d73 /Source/SPDatabaseDocument.m
parent8b9ff8d4aefa02a7f98e1f2afa14de842a8c6774 (diff)
downloadsequelpro-e0be0f0668619e4fb70e23d8e25b2680f12b6a12.tar.gz
sequelpro-e0be0f0668619e4fb70e23d8e25b2680f12b6a12.tar.bz2
sequelpro-e0be0f0668619e4fb70e23d8e25b2680f12b6a12.zip
- Fix saving of .spf files using unencrypted formats, encoding the content selection index set
Diffstat (limited to 'Source/SPDatabaseDocument.m')
-rw-r--r--Source/SPDatabaseDocument.m22
1 files changed, 22 insertions, 0 deletions
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index d9bdcd24..4d9c76bf 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -3207,6 +3207,18 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
// Determine whether to use encryption when adding the data
[spfStructure setObject:[spfDocData_temp objectForKey:@"encrypted"] forKey:@"encrypted"];
if (![[spfDocData_temp objectForKey:@"encrypted"] boolValue]) {
+
+ // Convert the content selection to encoded data
+ if ([[spfData objectForKey:@"session"] objectForKey:@"contentSelection"]) {
+ NSMutableDictionary *sessionInfo = [NSMutableDictionary dictionaryWithDictionary:[spfData objectForKey:@"session"]];
+ NSMutableData *dataToEncode = [[[NSMutableData alloc] init] autorelease];
+ NSKeyedArchiver *archiver = [[[NSKeyedArchiver alloc] initForWritingWithMutableData:dataToEncode] autorelease];
+ [archiver encodeObject:[sessionInfo objectForKey:@"contentSelection"] forKey:@"data"];
+ [archiver finishEncoding];
+ [sessionInfo setObject:dataToEncode forKey:@"contentSelection"];
+ [spfData setObject:sessionInfo forKey:@"session"];
+ }
+
[spfStructure setObject:spfData forKey:@"data"];
} else {
NSMutableData *dataToEncrypt = [[[NSMutableData alloc] init] autorelease];
@@ -4629,6 +4641,16 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase";
if ([[spf objectForKey:@"data"] isKindOfClass:[NSDictionary class]])
data = [NSMutableDictionary dictionaryWithDictionary:[spf objectForKey:@"data"]];
+
+ // If a content selection data key exists in the session, decode it
+ if ([[[data objectForKey:@"session"] objectForKey:@"contentSelection"] isKindOfClass:[NSData class]]) {
+ NSMutableDictionary *sessionInfo = [NSMutableDictionary dictionaryWithDictionary:[data objectForKey:@"session"]];
+ NSKeyedUnarchiver *unarchiver = [[[NSKeyedUnarchiver alloc] initForReadingWithData:[sessionInfo objectForKey:@"contentSelection"]] autorelease];
+ [sessionInfo setObject:[unarchiver decodeObjectForKey:@"data"] forKey:@"contentSelection"];
+ [unarchiver finishDecoding];
+ [data setObject:sessionInfo forKey:@"session"];
+ }
+
else if ([[spf objectForKey:@"data"] isKindOfClass:[NSData class]]) {
NSData *decryptdata = nil;
decryptdata = [[[NSMutableData alloc] initWithData:[(NSData *)[spf objectForKey:@"data"] dataDecryptedWithPassword:encryptpw]] autorelease];