1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-21 18:02:35 +01:00

try to escape last ffmpeg command on windows

also escape quote on linux

closes #2151
This commit is contained in:
Mikael Finstad 2024-09-28 14:33:13 +02:00
parent 93f47b9c35
commit b6645fa445
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

View File

@ -24,8 +24,16 @@ export function setCustomFfPath(path: string | undefined) {
customFfPath = path;
}
function escapeCliArg(arg: string) {
if (isWindows) {
// https://github.com/mifi/lossless-cut/issues/2151
return /[\s"&<>^|]/.test(arg) ? `"${arg.replaceAll('"', '""')}"` : arg;
}
return /[^\w-]/.test(arg) ? `'${arg.replaceAll("'", '\'"\'"\'')}'` : arg;
}
export function getFfCommandLine(cmd: string, args: readonly string[]) {
return `${cmd} ${args.map((arg) => (/[^\w-]/.test(arg) ? `'${arg}'` : arg)).join(' ')}`;
return `${cmd} ${args.map((arg) => escapeCliArg(arg)).join(' ')}`;
}
function getFfPath(cmd: string) {