Skip to content

Commit 3b72047

Browse files
authored
Merge pull request #245 from sylveon/master
FIx whitespace handling when invoking Python
2 parents 83d75ce + efb60b3 commit 3b72047

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

helpers/odm_python.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setlocal
44

5-
call %ODM_PATH%\win32env.bat
5+
call "%ODM_PATH%\win32env.bat"
66
python %*
77

8-
endlocal
8+
endlocal

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)