@@ -152,17 +152,19 @@ export class RemoteSSHResolver implements vscode.RemoteAuthorityResolver, vscode
152152 proxyStream = await proxyConnection . forwardOut ( '127.0.0.1' , 0 , destIP , destPort ) ;
153153 }
154154 } else if ( sshHostConfig [ 'ProxyCommand' ] ) {
155- const proxyArgs = ( sshHostConfig [ 'ProxyCommand' ] as unknown as string [ ] )
156- . map ( ( arg ) => `"${ arg . replace ( '%h' , sshHostName ) . replace ( '%p' , sshPort . toString ( ) ) . replace ( '%r' , sshUser ) } "` ) ;
157- const proxyCommand = proxyArgs . shift ( ) ! ;
158-
159- this . logger . trace ( `Spawning ProxyCommand: ${ proxyCommand } ${ proxyArgs . join ( ' ' ) } ` ) ;
155+ let proxyArgs = ( sshHostConfig [ 'ProxyCommand' ] as unknown as string [ ] )
156+ . map ( ( arg ) => arg . replace ( '%h' , sshHostName ) . replace ( '%p' , sshPort . toString ( ) ) . replace ( '%r' , sshUser ) ) ;
157+ let proxyCommand = proxyArgs . shift ( ) ! ;
160158
161159 let options = { } ;
162- if ( isWindows && / \. ( b a t | c m d ) " $ / . test ( proxyCommand ) ) {
160+ if ( isWindows && / \. ( b a t | c m d ) $ / . test ( proxyCommand ) ) {
161+ proxyCommand = `"${ proxyCommand } "` ;
162+ proxyArgs = proxyArgs . map ( ( arg ) => arg . includes ( ' ' ) ? `"${ arg } "` : arg ) ;
163163 options = { shell : true , windowsHide : true , windowsVerbatimArguments : true } ;
164164 }
165165
166+ this . logger . trace ( `Spawning ProxyCommand: ${ proxyCommand } ${ proxyArgs . join ( ' ' ) } ` ) ;
167+
166168 const child = cp . spawn ( proxyCommand , proxyArgs , options ) ;
167169 proxyStream = stream . Duplex . from ( { readable : child . stdout , writable : child . stdin } ) ;
168170 this . proxyCommandProcess = child ;
0 commit comments