File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff 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 ( )
You can’t perform that action at this time.
0 commit comments