From cc43896650676637e2b784a3fb224a17be2c7352 Mon Sep 17 00:00:00 2001 From: Janosch Maier Date: Tue, 29 Mar 2022 21:22:49 +0200 Subject: [PATCH] Replace exec with execFile in MacOS Quick Preview --- app/src/quickpreview/index.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/quickpreview/index.ts b/app/src/quickpreview/index.ts index f2d203304..59d3fff0b 100644 --- a/app/src/quickpreview/index.ts +++ b/app/src/quickpreview/index.ts @@ -1,5 +1,5 @@ -import { exec } from 'child_process'; +import { execFile } from 'child_process'; import path from 'path'; import { File } from 'mailspring-exports'; @@ -336,13 +336,14 @@ function _generateNextCrossplatformPreview() { } async function _generateQuicklookPreview({ filePath }: { filePath: string }) { - const dirQuoted = `"${path.dirname(filePath).replace(/"/g, '\\"')}"`; - const pathQuoted = `"${filePath.replace(/"/g, '\\"')}"`; + const dirQuoted = path.dirname(filePath).replace(/"/g, '\\"') + const pathQuoted = filePath.replace(/"/g, '\\"') return new Promise(resolve => { - const cmd = `qlmanage -t -f ${window.devicePixelRatio} -s ${ThumbnailWidth} -o ${dirQuoted} ${pathQuoted}`; + const cmd = '/usr/bin/qlmanage'; + const args = ['-t', "-f", `${window.devicePixelRatio}`, '-s', `${ThumbnailWidth}`, '-o', dirQuoted, pathQuoted] - exec(cmd, (error, stdout, stderr) => { + execFile(cmd, args, (error, stdout, stderr) => { // Note: sometimes qlmanage outputs to stderr but still successfully // produces a thumbnail. It complains about bad plugins pretty often. if (