From 2c76c8a968b109a5cd593975bcff1728d74de53f Mon Sep 17 00:00:00 2001 From: Jordan Chapelle Date: Wed, 16 Oct 2024 14:20:37 +0200 Subject: [PATCH] fix: Add a guard to secure file --- Mail/Views/Bottom sheets/ReportDisplayProblemView.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Mail/Views/Bottom sheets/ReportDisplayProblemView.swift b/Mail/Views/Bottom sheets/ReportDisplayProblemView.swift index 14f86d9aa..b7cf85f40 100644 --- a/Mail/Views/Bottom sheets/ReportDisplayProblemView.swift +++ b/Mail/Views/Bottom sheets/ReportDisplayProblemView.swift @@ -51,9 +51,10 @@ struct ReportDisplayProblemView: View { await tryOrDisplayError { // Download message let fileURL = try await mailboxManager.apiFetcher.download(messages: [message]) + guard let firstFileURL = fileURL.first else { throw MailError.unknownError } // Send it via Sentry - let fileAttachment = Attachment(path: fileURL.first!.path, - filename: fileURL.first!.lastPathComponent, + let fileAttachment = Attachment(path: firstFileURL.path, + filename: firstFileURL.lastPathComponent, contentType: "message/rfc822") _ = SentrySDK.capture(message: "Message display problem reported") { scope in scope.addAttachment(fileAttachment)