Skip to content

Commit bb77661

Browse files
committed
address CodeQL issue
1 parent a86afd6 commit bb77661

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Extension/src/Debugger/runWithoutDebuggingAdapter.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class RunWithoutDebuggingAdapter implements vscode.DebugAdapter {
117117
if (platform === 'win32') {
118118
cp.spawn('cmd.exe', ['/c', 'start', 'cmd.exe', '/K', cmdLine], { cwd, env, detached: true, stdio: 'ignore' }).unref();
119119
} else if (platform === 'darwin') {
120-
cp.spawn('osascript', ['-e', `tell application "Terminal" to do script "${cmdLine.replace(/"/g, '\\"')}"`], { cwd, env, detached: true, stdio: 'ignore' }).unref();
120+
cp.spawn('osascript', ['-e', `tell application "Terminal" to do script "${this.escapeQuotes(cmdLine)}"`], { cwd, env, detached: true, stdio: 'ignore' }).unref();
121121
} else if (platform === 'linux' && sessionIsWsl()) {
122122
cp.spawn('/mnt/c/Windows/System32/cmd.exe', ['/c', 'start', 'bash', '-c', `${cmdLine};read -p 'Press enter to continue...'`], { env, detached: true, stdio: 'ignore' }).unref();
123123
} else { // platform === 'linux'
@@ -186,8 +186,12 @@ export class RunWithoutDebuggingAdapter implements vscode.DebugAdapter {
186186
});
187187
}
188188

189+
private escapeQuotes(arg: string): string {
190+
return arg.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
191+
}
192+
189193
private quoteArg(arg: string): string {
190-
return /\s/.test(arg) ? `"${arg.replace(/"/g, '\\"')}"` : arg;
194+
return /\s/.test(arg) ? `"${this.escapeQuotes(arg)}"` : arg;
191195
}
192196

193197
private sendResponse(request: { command: string; seq: number; }, body: object): void {

0 commit comments

Comments
 (0)