From 59ac5769ad4f1c299c9f6f654b923174e500ff4a Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Mon, 25 Jul 2022 19:33:51 -0700 Subject: [PATCH] [Sandbox] Add Sandbox grants to places missing it The subdirectory parser, the CUEsheet reader, and the legacy XML playlist reader were missing grants for Sandbox access. Signed-off-by: Christopher Snowhill --- Playlist/PlaylistLoader.m | 2 ++ Playlist/XmlContainer.m | 7 +++++++ Plugins/CueSheet/CueSheet.m | 5 +++++ Plugins/CueSheet/CueSheet.xcodeproj/project.pbxproj | 2 ++ 4 files changed, 16 insertions(+) diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index 52124db65..f7ea25e32 100644 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -245,7 +245,9 @@ NSMutableDictionary *dictionaryWithPropertiesOfObject(id obj, NSArray *filterLis NSMutableArray *urls = [NSMutableArray array]; + const void *sbHandle = [[SandboxBroker sharedSandboxBroker] beginFolderAccess:[NSURL fileURLWithPath:path]]; NSArray *subpaths = [manager subpathsAtPath:path]; + [[SandboxBroker sharedSandboxBroker] endFolderAccess:sbHandle]; for(NSString *subpath in subpaths) { NSString *absoluteSubpath = [NSString pathWithComponents:@[path, subpath]]; diff --git a/Playlist/XmlContainer.m b/Playlist/XmlContainer.m index df2784477..0f615873a 100644 --- a/Playlist/XmlContainer.m +++ b/Playlist/XmlContainer.m @@ -10,6 +10,8 @@ #import "Logging.h" +#import "SandboxBroker.h" + @implementation XmlContainer + (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename { @@ -58,9 +60,14 @@ NSString *filename = [url path]; + const void *sbHandle = [[SandboxBroker sharedSandboxBroker] beginFolderAccess:url]; + NSString *contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error]; + + [[SandboxBroker sharedSandboxBroker] endFolderAccess:sbHandle]; + if(!contents) { ALog(@"Error: %@", error); return nil; diff --git a/Plugins/CueSheet/CueSheet.m b/Plugins/CueSheet/CueSheet.m index 063a1ebbd..65f6b4114 100644 --- a/Plugins/CueSheet/CueSheet.m +++ b/Plugins/CueSheet/CueSheet.m @@ -13,6 +13,8 @@ #import "Logging.h" +#import "SandboxBroker.h" + @implementation CueSheet + (id)cueSheetWithFile:(NSString *)filename { @@ -63,6 +65,8 @@ - (void)parseFile:(NSString *)filename { NSStringEncoding encoding; NSError *error = nil; + id sandboxBrokerClass = NSClassFromString(@"SandboxBroker"); + const void *sbHandle = [[sandboxBrokerClass sharedSandboxBroker] beginFolderAccess:[NSURL fileURLWithPath:filename]]; NSString *contents = [NSString stringWithContentsOfFile:filename usedEncoding:&encoding error:&error]; if(error) { error = nil; @@ -80,6 +84,7 @@ error = nil; contents = [NSString stringWithContentsOfFile:filename encoding:NSISOLatin1StringEncoding error:&error]; } + [[sandboxBrokerClass sharedSandboxBroker] endFolderAccess:sbHandle]; if(error || !contents) { ALog(@"Could not open file...%@ %@ %@", filename, contents, error); return; diff --git a/Plugins/CueSheet/CueSheet.xcodeproj/project.pbxproj b/Plugins/CueSheet/CueSheet.xcodeproj/project.pbxproj index dc7c62a4f..ce82bde99 100644 --- a/Plugins/CueSheet/CueSheet.xcodeproj/project.pbxproj +++ b/Plugins/CueSheet/CueSheet.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ 17DA346C0CC04FCD0003F6B2 /* CueSheetMetadataReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CueSheetMetadataReader.h; sourceTree = ""; }; 17DA346D0CC04FCD0003F6B2 /* CueSheetMetadataReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CueSheetMetadataReader.m; sourceTree = ""; }; 32DBCF630370AF2F00C91783 /* CueSheet_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CueSheet_Prefix.pch; sourceTree = ""; }; + 832EE93A288F888600B03467 /* SandboxBroker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SandboxBroker.h; path = ../../Utils/SandboxBroker.h; sourceTree = ""; }; 833F68371CDBCAB200AFB9F0 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/InfoPlist.strings; sourceTree = ""; }; 834A42B2287AF59900EB9D9B /* AudioChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudioChunk.h; path = ../../Audio/Chain/AudioChunk.h; sourceTree = ""; }; 835C888E22CC1883001B4B3F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -91,6 +92,7 @@ 08FB77AFFE84173DC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( + 832EE93A288F888600B03467 /* SandboxBroker.h */, 834A42B2287AF59900EB9D9B /* AudioChunk.h */, 839DA7D3274A2FD4001B18E5 /* NSDictionary+Merge.h */, 839DA7D0274A2EA9001B18E5 /* AudioMetadataReader.h */,