Skip to content

Commit 123fe01

Browse files
authored
fix: Avoid double escaping of ProxyCommand on Windows (#3664)
Fixes #2853
1 parent 0914225 commit 123fe01

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cli/configssh.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,16 @@ func configSSH() *cobra.Command {
280280
"\tLogLevel ERROR",
281281
)
282282
if !skipProxyCommand {
283+
// In SSH configs, strings inside "" are interpreted literally and there
284+
// is no need to e.g. escape backslashes (common on Windows platforms).
285+
// We will escape the quotes, though.
286+
escapedBinaryFile := strings.ReplaceAll(binaryFile, "\"", "\\\"")
283287
if !wireguard {
284-
configOptions = append(configOptions, fmt.Sprintf("\tProxyCommand %q --global-config %q ssh --stdio %s", binaryFile, root, hostname))
288+
//nolint:gocritic // We don't want to use %q here, see above.
289+
configOptions = append(configOptions, fmt.Sprintf("\tProxyCommand \"%s\" --global-config \"%s\" ssh --stdio %s", escapedBinaryFile, root, hostname))
285290
} else {
286-
configOptions = append(configOptions, fmt.Sprintf("\tProxyCommand %q --global-config %q ssh --wireguard --stdio %s", binaryFile, root, hostname))
291+
//nolint:gocritic // We don't want to use %q here, see above.
292+
configOptions = append(configOptions, fmt.Sprintf("\tProxyCommand \"%s\" --global-config \"%s\" ssh --wireguard --stdio %s", escapedBinaryFile, root, hostname))
287293
}
288294
}
289295

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy