This commit is contained in:
michael starke
2016-02-22 10:56:23 +01:00
parent 3abf1982b1
commit dee07d1ecd

View File

@@ -205,18 +205,30 @@ NSString *const kMPDeprecatedSettingsKeyShowMenuItem = @"Sh
Database file paths was stored as plain text in keyfile mapping. Database file paths was stored as plain text in keyfile mapping.
We only need to store the key file ulr in plain text, thus hashing the path is sufficent We only need to store the key file ulr in plain text, thus hashing the path is sufficent
*/ */
NSDictionary<NSString *, NSString *> *plainTextDict = [[NSUserDefaults standardUserDefaults] dictionaryForKey:kMPSettingsKeyRememeberdKeysForDatabases]; NSDictionary<NSString *, NSString *> *currentMapping = [[NSUserDefaults standardUserDefaults] dictionaryForKey:kMPSettingsKeyRememeberdKeysForDatabases];
if(!plainTextDict) { if(!currentMapping) {
return; return;
} }
NSMutableDictionary *hashedDict = [[NSMutableDictionary alloc] initWithCapacity:plainTextDict.count]; NSMutableDictionary *hashedDict = [[NSMutableDictionary alloc] initWithCapacity:MAX(1,currentMapping.count)];
for(NSString *key in plainTextDict) { BOOL didHash = NO;
NSString *digest = key.sha1HexDigest; for(NSString *key in currentMapping) {
if(digest) { NSURL *fileURL = [NSURL URLWithString:key];
hashedDict[key.sha1HexDigest] = plainTextDict[key]; /* Only hash file paths */
if(fileURL.isFileURL) {
NSString *digest = key.sha1HexDigest;
if(digest) {
hashedDict[key.sha1HexDigest] = currentMapping[key];
didHash = YES;
}
}
/* keep all hasehd or unknown data */
else {
hashedDict[key] = currentMapping[key];
} }
} }
[[NSUserDefaults standardUserDefaults] setObject:hashedDict forKey:kMPSettingsKeyRememeberdKeysForDatabases]; if(didHash) {
[[NSUserDefaults standardUserDefaults] setObject:hashedDict forKey:kMPSettingsKeyRememeberdKeysForDatabases];
}
} }
@end @end