Enable NSSecureCoding when unarchiving presets.
This commit is contained in:
1 parent
b0881c91a9
commit
133df13f0d
1 file changed
+25
-16
+25
-16
@@ -60,36 +60,45 @@ NSString *SBPresetManagerUpdatedNotification = @"SBPresetManagerUpdatedNotificat
|
|||||||
[self updateNotification];
|
[self updateNotification];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)appSupportPath
|
- (NSURL *)appSupportURL
|
||||||
{
|
{
|
||||||
NSArray *allPaths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
NSUserDomainMask,
|
return [[fileManager URLsForDirectory:NSApplicationSupportDirectory
|
||||||
YES);
|
inDomains:NSUserDomainMask].firstObject URLByAppendingPathComponent:@"Subler"];
|
||||||
return [allPaths.firstObject stringByAppendingPathComponent:@"Subler"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)loadPresets
|
- (BOOL)loadPresets
|
||||||
{
|
{
|
||||||
NSString *file;
|
NSURL *appSupportURL = [self appSupportURL];
|
||||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
||||||
NSString *appSupportPath = [self appSupportPath];
|
|
||||||
MP42Metadata *newPreset;
|
|
||||||
|
|
||||||
if (!appSupportPath) {
|
if (!appSupportURL) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSDirectoryEnumerator *dirEnum = [fileManager enumeratorAtPath:appSupportPath];
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
while ((file = [dirEnum nextObject])) {
|
NSDirectoryEnumerator *directoryEnumerator =
|
||||||
if ([file.pathExtension isEqualToString:@"sbpreset"]) {
|
[fileManager enumeratorAtURL:appSupportURL
|
||||||
|
includingPropertiesForKeys:@[NSURLNameKey, NSURLIsDirectoryKey]
|
||||||
|
options:NSDirectoryEnumerationSkipsHiddenFiles
|
||||||
|
errorHandler:nil];
|
||||||
|
|
||||||
|
for (NSURL *fileURL in directoryEnumerator) {
|
||||||
|
NSNumber *isDirectory = nil;
|
||||||
|
[fileURL getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:nil];
|
||||||
|
|
||||||
|
if ([isDirectory boolValue] == NO && [fileURL.pathExtension isEqualToString:@"sbpreset"]) {
|
||||||
@try {
|
@try {
|
||||||
newPreset = [NSKeyedUnarchiver unarchiveObjectWithFile:[appSupportPath stringByAppendingPathComponent:file]];
|
NSData *queue = [NSData dataWithContentsOfURL:fileURL];
|
||||||
|
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:queue];
|
||||||
|
unarchiver.requiresSecureCoding = YES;
|
||||||
|
MP42Metadata *newPreset = [unarchiver decodeObjectOfClass:[MP42Metadata class] forKey:NSKeyedArchiveRootObjectKey];
|
||||||
|
[unarchiver finishDecoding];
|
||||||
|
|
||||||
|
[_presets addObject:newPreset];
|
||||||
}
|
}
|
||||||
@catch (NSException *exception) {
|
@catch (NSException *exception) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
[_presets addObject:newPreset];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user