From da82bd7e7838d8eac4a54602bf23c77a90c2071f Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Wed, 9 Mar 2022 01:20:56 +0100 Subject: [PATCH] Fix completion when password name contains quotes Signed-off-by: Patrick Decat --- internal/action/completion.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/action/completion.go b/internal/action/completion.go index 2d4c99fa63..7779c26ddf 100644 --- a/internal/action/completion.go +++ b/internal/action/completion.go @@ -14,7 +14,7 @@ import ( "github.com/urfave/cli/v2" ) -var escapeRegExp = regexp.MustCompile(`(\s|\(|\)|\<|\>|\&|\;|\#|\\|\||\*|\?)`) +var escapeRegExp = regexp.MustCompile(`('|"|\s|\(|\)|\<|\>|\&|\;|\#|\\|\||\*|\?)`) // bashEscape Escape special characters with `\`. func bashEscape(s string) string { @@ -22,6 +22,12 @@ func bashEscape(s string) string { if c == `\` { return `\\\\` } + if c == `'` { + return `\` + c + } + if c == `"` { + return `\\\` + c + } return `\\` + c }) }