[Sandbox Config] Correctly test paths for files

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
swiftingly
Christopher Snowhill 2022-06-29 12:11:01 -07:00
parent 61778b7165
commit b24b9744c1
1 changed files with 5 additions and 2 deletions

View File

@ -48,7 +48,7 @@
ALog(@"Stale bookmark for path: %@, with error: %@", token.path, [err localizedDescription]); ALog(@"Stale bookmark for path: %@, with error: %@", token.path, [err localizedDescription]);
continue; continue;
} }
[self addObject:@{ @"path": token.path, @"valid": (isStale ? NSLocalizedPrefString(@"ValidNo") : NSLocalizedPrefString(@"ValidYes")) }]; [self addObject:@{ @"path": token.path, @"valid": (isStale ? NSLocalizedPrefString(@"ValidNo") : NSLocalizedPrefString(@"ValidYes")), @"isFolder": @(token.folder) }];
} }
} }
} }
@ -121,11 +121,14 @@
id sandboxBrokerClass = NSClassFromString(@"SandboxBroker"); id sandboxBrokerClass = NSClassFromString(@"SandboxBroker");
for(NSDictionary *entry in [self arrangedObjects]) { for(NSDictionary *entry in [self arrangedObjects]) {
if([[entry objectForKey:@"valid"] isEqualToString:NSLocalizedPrefString(@"ValidYes")]) { if([[entry objectForKey:@"valid"] isEqualToString:NSLocalizedPrefString(@"ValidYes")]) {
BOOL isFolder = [[entry objectForKey:@"isFolder"] boolValue];
NSString *path = [entry objectForKey:@"path"]; NSString *path = [entry objectForKey:@"path"];
if(path && [path length]) { if(path && [path length]) {
NSURL *testPath = [NSURL fileURLWithPath:[entry objectForKey:@"path"]]; NSURL *testPath = [NSURL fileURLWithPath:[entry objectForKey:@"path"]];
if([sandboxBrokerClass isPath:url aSubdirectoryOf:testPath]) if((isFolder && [sandboxBrokerClass isPath:url aSubdirectoryOf:testPath]) ||
(!isFolder && [[url path] isEqualToString:path])) {
return YES; return YES;
}
} }
} }
} }