[Sandbox Configuration] Do more checks on test

When testing the path for whether it's in storage, run more tests to
make sure we only care about valid paths, and a path that actually has
a string.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
swiftingly
Christopher Snowhill 2022-06-21 16:16:47 -07:00
parent 3d8f470206
commit cc46c5a5ee
1 changed files with 8 additions and 3 deletions

View File

@ -119,9 +119,14 @@
- (BOOL)matchesPath:(NSURL *)url {
id sandboxBrokerClass = NSClassFromString(@"SandboxBroker");
for(NSDictionary *entry in [self arrangedObjects]) {
NSURL *testPath = [NSURL fileURLWithPath:[entry objectForKey:@"path"]];
if([sandboxBrokerClass isPath:url aSubdirectoryOf:testPath])
return YES;
if([[entry objectForKey:@"valid"] isEqualToString:NSLocalizedPrefString(@"ValidYes")]) {
NSString *path = [entry objectForKey:@"path"];
if(path && [path length]) {
NSURL *testPath = [NSURL fileURLWithPath:[entry objectForKey:@"path"]];
if([sandboxBrokerClass isPath:url aSubdirectoryOf:testPath])
return YES;
}
}
}
return NO;
}