From 6432f00f0d026c61f683c83ded4d2e15317e927e Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 14 May 2024 01:30:36 +0900 Subject: 0.52.1 --- src/util/util_windows.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/util/util_windows.go') diff --git a/src/util/util_windows.go b/src/util/util_windows.go index f29e33be..3a4ab570 100644 --- a/src/util/util_windows.go +++ b/src/util/util_windows.go @@ -7,6 +7,7 @@ import ( "os" "os/exec" "path/filepath" + "regexp" "strings" "sync/atomic" "syscall" @@ -20,6 +21,8 @@ const ( shellTypePowerShell ) +var escapeRegex = regexp.MustCompile(`[&|<>()^%!"]`) + type Executor struct { shell string shellType shellType @@ -131,7 +134,9 @@ func escapeArg(s string) string { b = append(b, '\\') } b = append(b, '"') - return string(b) + return escapeRegex.ReplaceAllStringFunc(string(b), func(match string) string { + return "^" + match + }) } func (x *Executor) QuoteEntry(entry string) string { -- cgit v1.2.3