Skip to content

Commit fcaeb69

Browse files
committed
More accurate escaping and quoting for debug commands in terminal. Fix #145265
1 parent b0c5a28 commit fcaeb69

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/vs/workbench/contrib/debug/node/terminals.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export function prepareCommand(shell: string, args: string[], cwd?: string, env?
121121

122122
quote = (s: string) => {
123123
s = s.replace(/\"/g, '""');
124-
return (s.indexOf(' ') >= 0 || s.indexOf('"') >= 0 || s.length === 0) ? `"${s}"` : s;
124+
return (' "><!^&'.split('').some(char => s.includes(char)) || s.length === 0) ? `"${s}"` : s;
125125
};
126126

127127
if (cwd) {
@@ -154,8 +154,8 @@ export function prepareCommand(shell: string, args: string[], cwd?: string, env?
154154
case ShellType.bash: {
155155

156156
quote = (s: string) => {
157-
s = s.replace(/(["'\\\$])/g, '\\$1');
158-
return (s.indexOf(' ') >= 0 || s.indexOf(';') >= 0 || s.length === 0) ? `"${s}"` : s;
157+
s = s.replace(/(["'\\\$!><#()\[\]*&^])/g, '\\$1');
158+
return (' ;'.split('').some(char => s.includes(char)) || s.length === 0) ? `"${s}"` : s;
159159
};
160160

161161
const hardQuote = (s: string) => {

0 commit comments

Comments
 (0)