File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
main/kotlin/com/coder/gateway/sdk Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -195,13 +195,15 @@ class CoderCLIManager @JvmOverloads constructor(
195
195
}
196
196
}
197
197
198
+ var escapeRegex = """ (["\\])""" .toRegex()
199
+
198
200
/* *
199
201
* Escape a command argument by wrapping it in double quotes and escaping
200
- * any double quotes in the argument. For example, echo "test" becomes
201
- * "echo \"test \"".
202
+ * any slashes and double quotes in the argument. For example, echo "te\st"
203
+ * becomes "echo \"te\\st \"".
202
204
*/
203
205
private fun escape (s : String ): String {
204
- return " \" " + s.replace(" \" " , " \\\ "" ) + " \" "
206
+ return " \" " + s.replace(escapeRegex , """ \\$1 " "" ) + " \" "
205
207
}
206
208
207
209
/* *
Original file line number Diff line number Diff line change @@ -424,6 +424,7 @@ class CoderCLIManagerTest extends Specification {
424
424
[" foo-bar" ] | " no-related-blocks" | " append-no-related-blocks" | " no-related-blocks" | null
425
425
[" foo-bar" ] | " no-newline" | " append-no-newline" | " no-blocks" | null
426
426
[" header" ] | null | " header-command" | " blank" | " my-header-command \" test\" "
427
+ [" header" ] | null | " header-command-windows" | " blank" | $/ C:\P rogram Files\M y Header Command\" also has quotes"\H eaderCommand.exe/ $
427
428
}
428
429
429
430
def " fails if config is malformed" () {
You can’t perform that action at this time.
0 commit comments