mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 10:32:26 +00:00
Merge branch 'fix_broken_keyfile_remembering'
This commit is contained in:
@@ -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;
|
||||||
|
for(NSString *key in currentMapping) {
|
||||||
|
NSURL *fileURL = [NSURL URLWithString:key];
|
||||||
|
/* Only hash file paths */
|
||||||
|
if(fileURL.isFileURL) {
|
||||||
NSString *digest = key.sha1HexDigest;
|
NSString *digest = key.sha1HexDigest;
|
||||||
if(digest) {
|
if(digest) {
|
||||||
hashedDict[key.sha1HexDigest] = plainTextDict[key];
|
hashedDict[key.sha1HexDigest] = currentMapping[key];
|
||||||
|
didHash = YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* keep all hasehd or unknown data */
|
||||||
|
else {
|
||||||
|
hashedDict[key] = currentMapping[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(didHash) {
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:hashedDict forKey:kMPSettingsKeyRememeberdKeysForDatabases];
|
[[NSUserDefaults standardUserDefaults] setObject:hashedDict forKey:kMPSettingsKeyRememeberdKeysForDatabases];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Reference in New Issue
Block a user