From befbdbbf710ceb889aa0d52261b9a4c92aadd64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20Kadir=20Ak=C4=B1n?= Date: Mon, 10 Aug 2026 20:46:05 +0300 Subject: [PATCH] fix: make PPTX import sandbox-safe --- Textream/Textream/PresentationNotesExtractor.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Textream/Textream/PresentationNotesExtractor.swift b/Textream/Textream/PresentationNotesExtractor.swift index 01ce7d2..ab444fe 100644 --- a/Textream/Textream/PresentationNotesExtractor.swift +++ b/Textream/Textream/PresentationNotesExtractor.swift @@ -46,10 +46,20 @@ enum PresentationNotesExtractor { try fileManager.createDirectory(at: tempDir, withIntermediateDirectories: true) defer { try? fileManager.removeItem(at: tempDir) } + // Copy the security-scoped document into Textream's own temporary + // directory before handing it to a child process. This keeps PPTX + // import reliable inside the Mac App Store sandbox. + let localArchive = tempDir.appendingPathComponent("presentation.pptx") + do { + try fileManager.copyItem(at: url, to: localArchive) + } catch { + throw ExtractionError.extractionFailed("Could not read PPTX file.") + } + // Unzip using Process let process = Process() process.executableURL = URL(fileURLWithPath: "/usr/bin/unzip") - process.arguments = ["-o", "-q", url.path, "-d", tempDir.path] + process.arguments = ["-o", "-q", localArchive.path, "-d", tempDir.path] process.standardOutput = FileHandle.nullDevice process.standardError = FileHandle.nullDevice try process.run()