Skip to content

Commit fca210c

Browse files
authored
Git - escape shell-sensitive characters (microsoft#236849)
1 parent 2e5cbd4 commit fca210c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

extensions/git/src/git.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,15 @@ function getGitErrorCode(stderr: string): string | undefined {
348348
return undefined;
349349
}
350350

351-
// https://github.com/microsoft/vscode/issues/89373
352-
// https://github.com/git-for-windows/git/issues/2478
353351
function sanitizePath(path: string): string {
354-
return path.replace(/^([a-z]):\\/i, (_, letter) => `${letter.toUpperCase()}:\\`);
352+
return path
353+
// Drive letter
354+
// https://github.com/microsoft/vscode/issues/89373
355+
// https://github.com/git-for-windows/git/issues/2478
356+
.replace(/^([a-z]):\\/i, (_, letter) => `${letter.toUpperCase()}:\\`)
357+
// Shell-sensitive characters
358+
// https://github.com/microsoft/vscode/issues/133566
359+
.replace(/(["'\\\$!><#()\[\]*&^| ;{}?`])/g, '\\$1');
355360
}
356361

357362
const COMMIT_FORMAT = '%H%n%aN%n%aE%n%at%n%ct%n%P%n%D%n%B';

0 commit comments

Comments
 (0)