Skip to content

Commit

Permalink
fix: properly escape params passed to exec
Browse files Browse the repository at this point in the history
  • Loading branch information
lightpohl committed Dec 11, 2024
1 parent 88df918 commit 2a65931
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions bin/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const escapeArgForShell = (arg) => {

if (/[^A-Za-z0-9_/:=-]/.test(result)) {
if (isWin) {
return null;
return `"${result}"`;
} else {
result = "'" + result.replace(/'/g, "'\\''") + "'";
result = result
Expand Down Expand Up @@ -710,11 +710,14 @@ const runExec = async ({
);

const execCmd = exec
.replace(/{{episode_path}}/g, `"${outputPodcastPath}"`)
.replace(/{{episode_path_base}}/g, `"${basePath}"`)
.replace(/{{episode_filename}}/g, `"${episodeFilename}"`)
.replace(/{{episode_filename_base}}/g, `"${episodeFilenameBase}"`)
.replace(/{{url}}/g, `"${episodeAudioUrl}"`);
.replace(/{{episode_path}}/g, escapeArgForShell(outputPodcastPath))
.replace(/{{episode_path_base}}/g, escapeArgForShell(basePath))
.replace(/{{episode_filename}}/g, escapeArgForShell(episodeFilename))
.replace(
/{{episode_filename_base}}/g,
escapeArgForShell(episodeFilenameBase)
)
.replace(/{{url}}/g, escapeArgForShell(episodeAudioUrl));

await execWithPromise(execCmd, { stdio: "ignore" });
};
Expand Down

0 comments on commit 2a65931

Please sign in to comment.