mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-10 08:45:56 +01:00
More accurate escaping and quoting for debug commands in terminal. Fix #145265
This commit is contained in:
@@ -121,7 +121,7 @@ export function prepareCommand(shell: string, args: string[], cwd?: string, env?
|
||||
|
||||
quote = (s: string) => {
|
||||
s = s.replace(/\"/g, '""');
|
||||
return (s.indexOf(' ') >= 0 || s.indexOf('"') >= 0 || s.length === 0) ? `"${s}"` : s;
|
||||
return (' "><!^&'.split('').some(char => s.includes(char)) || s.length === 0) ? `"${s}"` : s;
|
||||
};
|
||||
|
||||
if (cwd) {
|
||||
@@ -154,8 +154,8 @@ export function prepareCommand(shell: string, args: string[], cwd?: string, env?
|
||||
case ShellType.bash: {
|
||||
|
||||
quote = (s: string) => {
|
||||
s = s.replace(/(["'\\\$])/g, '\\$1');
|
||||
return (s.indexOf(' ') >= 0 || s.indexOf(';') >= 0 || s.length === 0) ? `"${s}"` : s;
|
||||
s = s.replace(/(["'\\\$!><#()\[\]*&^])/g, '\\$1');
|
||||
return (' ;'.split('').some(char => s.includes(char)) || s.length === 0) ? `"${s}"` : s;
|
||||
};
|
||||
|
||||
const hardQuote = (s: string) => {
|
||||
|
||||
Reference in New Issue
Block a user