Shell escape config.odm_path

pull/245/head
Piero Toffanin 2025-08-23 13:57:25 -04:00
rodzic 199904679b
commit efb60b33dc
1 zmienionych plików z 10 dodań i 1 usunięć

Wyświetl plik

@ -127,8 +127,17 @@ module.exports = {
const env = utils.clone(process.env);
env.ODM_OPTIONS_TMP_FILE = utils.tmpPath(".json");
env.ODM_PATH = config.odm_path;
const shEscape = s => {
if (/[^A-Za-z0-9_\/:=-]/.test(s)) {
s = "'"+s.replace(/'/g,"'\\''")+"'";
s = s.replace(/^(?:'')+/g, '')
.replace(/\\'''/g, "\\'" );
}
return s;
}
let childProcess = spawn(pythonExe, [path.join(__dirname, "..", "helpers", "odmOptionsToJson.py"),
"--project-path", config.odm_path, "bogusname"], { env, stdio: 'inherit', shell: true });
"--project-path", shEscape(`"${config.odm_path}"`), "bogusname"], { env, stdio: 'inherit', shell: true });
// Cleanup on done
let handleResult = (err, result) => {