Skip to content

Commit efb60b3

Browse files
committed
Shell escape config.odm_path
1 parent 1999046 commit efb60b3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

libs/odmRunner.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,17 @@ module.exports = {
127127
const env = utils.clone(process.env);
128128
env.ODM_OPTIONS_TMP_FILE = utils.tmpPath(".json");
129129
env.ODM_PATH = config.odm_path;
130+
const shEscape = s => {
131+
if (/[^A-Za-z0-9_\/:=-]/.test(s)) {
132+
s = "'"+s.replace(/'/g,"'\\''")+"'";
133+
s = s.replace(/^(?:'')+/g, '')
134+
.replace(/\\'''/g, "\\'" );
135+
}
136+
return s;
137+
}
138+
130139
let childProcess = spawn(pythonExe, [path.join(__dirname, "..", "helpers", "odmOptionsToJson.py"),
131-
"--project-path", config.odm_path, "bogusname"], { env, stdio: 'inherit', shell: true });
140+
"--project-path", shEscape(`"${config.odm_path}"`), "bogusname"], { env, stdio: 'inherit', shell: true });
132141

133142
// Cleanup on done
134143
let handleResult = (err, result) => {

0 commit comments

Comments
 (0)