Skip to content

Commit 565fd78

Browse files
committed
fix: escape ampersand and question mark in ProxyCommand
Fixes #479.
1 parent 16b9788 commit 565fd78

File tree

1 file changed

+4
-2
lines changed
  • src/main/kotlin/com/coder/gateway/util

1 file changed

+4
-2
lines changed

src/main/kotlin/com/coder/gateway/util/Escape.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ fun escape(s: String): String {
1212
if (s.contains("\n")) {
1313
throw Exception("argument cannot contain newlines")
1414
}
15-
if (s.contains(" ") || s.contains("\t")) {
16-
return "\"" + s.replace("\"", "\\\"") + "\""
15+
if (s.contains(" ") || s.contains("\t") || s.contains("&") || s.contains("?")) {
16+
// See https://github.com/coder/jetbrains-coder/issues/479
17+
// Escape existing " and &
18+
return "\"" + s.replace("\"", "\\\"").replace("&", "\\&").replace("?", "\\?") + "\""
1719
}
1820
return s.replace("\"", "\\\"")
1921
}

0 commit comments

Comments
 (0)