Skip to content

Commit dcb444b

Browse files
datlechinCopilot
andauthored
Update TablePro/Core/Services/ExportService.swift
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 8683a5a commit dcb444b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

TablePro/Core/Services/ExportService.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,17 @@ final class ExportService: ObservableObject {
725725
// Use gzip to compress the file
726726
let process = Process()
727727
process.executableURL = URL(fileURLWithPath: gzipPath)
728-
process.arguments = ["-c", source.path]
729728

729+
// Derive a sanitized, non-encoded filesystem path for the source
730+
let sanitizedSourcePath = source.standardizedFileURL.path(percentEncoded: false)
731+
732+
// Basic validation to avoid passing obviously malformed paths to the process
733+
if sanitizedSourcePath.contains("\0") ||
734+
sanitizedSourcePath.contains(where: { $0.isNewline }) {
735+
throw ExportError.exportFailed("Invalid source path for compression")
736+
}
737+
738+
process.arguments = ["-c", sanitizedSourcePath]
730739
let outputFile = try FileHandle(forWritingTo: destination)
731740
defer {
732741
try? outputFile.close()

0 commit comments

Comments
 (0)