fix: avoid shell interpolation in image conversion commands

This commit is contained in:
XIN PENG
2026-02-17 08:58:41 -08:00
parent 814380b85c
commit 479bbb240f
2 changed files with 63 additions and 3 deletions
+3 -3
View File
@@ -1,4 +1,4 @@
import { execSync } from "node:child_process"
import { execFileSync } from "node:child_process"
import { existsSync, mkdtempSync, unlinkSync, writeFileSync, readFileSync } from "node:fs"
import { tmpdir } from "node:os"
import { join } from "node:path"
@@ -57,7 +57,7 @@ export function convertImageToJpeg(inputPath: string, mimeType: string): string
try {
if (process.platform === "darwin") {
try {
execSync(`sips -s format jpeg "${inputPath}" --out "${outputPath}"`, {
execFileSync("sips", ["-s", "format", "jpeg", inputPath, "--out", outputPath], {
stdio: "pipe",
encoding: "utf-8",
})
@@ -72,7 +72,7 @@ export function convertImageToJpeg(inputPath: string, mimeType: string): string
}
try {
execSync(`convert "${inputPath}" "${outputPath}"`, {
execFileSync("convert", [inputPath, outputPath], {
stdio: "pipe",
encoding: "utf-8",
})