Skip to content

Commit

Permalink
Wrap access of itemUrl in security scoping
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Apr 17, 2024
1 parent 59928a6 commit b80afca
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate {
return
}

Logger.shareViewController.info(
"""
Instantiated with itemIdentifiers:
\(itemIdentifiers.map { $0.rawValue }, privacy: .public)
"""
)

Task {
await processItemIdentifier(firstItem)
}
Expand All @@ -72,11 +79,16 @@ class ShareViewController: NSViewController, ShareViewDataSourceUIDelegate {

do {
let itemUrl = try await manager.getUserVisibleURL(for: itemIdentifier)
guard itemUrl.startAccessingSecurityScopedResource() else {
Logger.shareViewController.error("Could not access scoped resource for item url!")
return
}
await updateDisplay(itemUrl: itemUrl)
shareDataSource.uiDelegate = self
shareDataSource.sharesTableView = tableView
shareDataSource.loadItem(url: itemUrl)
optionsView.dataSource = shareDataSource
itemUrl.stopAccessingSecurityScopedResource()
} catch let error {
let errorString = "Error processing item: \(error)"
Logger.shareViewController.error("\(errorString, privacy: .public)")
Expand Down

0 comments on commit b80afca

Please sign in to comment.