diff --git a/Shared/Importers/NNWThemeDocument.swift b/Shared/Importers/NNWThemeDocument.swift index 63956a9fe..c9a711f55 100644 --- a/Shared/Importers/NNWThemeDocument.swift +++ b/Shared/Importers/NNWThemeDocument.swift @@ -7,7 +7,6 @@ // import SwiftUI -import Account import UniformTypeIdentifiers public struct NNWThemeDocument: FileDocument { @@ -21,7 +20,10 @@ public struct NNWThemeDocument: FileDocument { } public init(configuration: ReadConfiguration) throws { - + guard let _ = configuration.file.regularFileContents else { + throw CocoaError(.fileReadCorruptFile) + } + return } public func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper { diff --git a/iOS/Settings/Appearance/ArticleThemeManagerView.swift b/iOS/Settings/Appearance/ArticleThemeManagerView.swift index efe0a2832..a1655d750 100644 --- a/iOS/Settings/Appearance/ArticleThemeManagerView.swift +++ b/iOS/Settings/Appearance/ArticleThemeManagerView.swift @@ -44,8 +44,12 @@ struct ArticleThemeManagerView: View { switch result { case .success(let success): do { - let theme = try ArticleTheme(path: success.path, isAppTheme: false) - showImportConfirmationAlert = (theme, true) + let url = URL(fileURLWithPath: success.path) + if url.startAccessingSecurityScopedResource() { + let theme = try ArticleTheme(path: success.path, isAppTheme: false) + showImportConfirmationAlert = (theme, true) + url.stopAccessingSecurityScopedResource() + } } catch { showImportErrorAlert = (error, true) } diff --git a/iOS/Settings/General/SettingsView.swift b/iOS/Settings/General/SettingsView.swift index c19c87e94..79d046156 100644 --- a/iOS/Settings/General/SettingsView.swift +++ b/iOS/Settings/General/SettingsView.swift @@ -117,13 +117,17 @@ struct SettingsView: View { .fileImporter(isPresented: $viewModel.showImportView, allowedContentTypes: OPMLDocument.readableContentTypes) { result in switch result { case .success(let url): - viewModel.importAccount!.importOPML(url) { importResult in - switch importResult { - case .success(_): - viewModel.showImportSuccess = true - case .failure(let error): - viewModel.importExportError = error - viewModel.showImportExportError = true + if url.startAccessingSecurityScopedResource() { + viewModel.importAccount!.importOPML(url) { importResult in + switch importResult { + case .success(_): + viewModel.showImportSuccess = true + url.stopAccessingSecurityScopedResource() + case .failure(let error): + viewModel.importExportError = error + viewModel.showImportExportError = true + url.stopAccessingSecurityScopedResource() + } } } case .failure(let error):