File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -589,12 +589,20 @@ export class Remote {
589
589
}
590
590
591
591
const escape = ( str : string ) : string => `"${ str . replace ( / " / g, '\\"' ) } "`
592
+ // Escape a command line to be executed by the Coder binary, so ssh doesn't substitute variables.
593
+ const escapeSubcommand : ( str : string ) => string =
594
+ os . platform ( ) === "win32"
595
+ ? // On Windows variables are %VAR%, and we need to use double quotes.
596
+ ( str ) => escape ( str ) . replace ( / % / g, "%%" )
597
+ : // On *nix we can use single quotes to escape $VARS.
598
+ // Note single quotes cannot be escaped inside single quotes.
599
+ ( str ) => `'${ str . replace ( / ' / g, "'\\''" ) } '`
592
600
593
601
// Add headers from the header command.
594
602
let headerArg = ""
595
603
const headerCommand = getHeaderCommand ( vscode . workspace . getConfiguration ( ) )
596
604
if ( typeof headerCommand === "string" && headerCommand . trim ( ) . length > 0 ) {
597
- headerArg = ` --header-command ${ escape ( headerCommand ) } `
605
+ headerArg = ` --header-command ${ escapeSubcommand ( headerCommand ) } `
598
606
}
599
607
let logArg = ""
600
608
if ( hasCoderLogs ) {
You can’t perform that action at this time.
0 commit comments