Skip to content

Commit

Permalink
Fix completion when password name contains quotes
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Decat <pdecat@gmail.com>
  • Loading branch information
pdecat committed Mar 9, 2022
1 parent b5236f7 commit da82bd7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/action/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ 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 {
return escapeRegExp.ReplaceAllStringFunc(s, func(c string) string {
if c == `\` {
return `\\\\`
}
if c == `'` {
return `\` + c
}
if c == `"` {
return `\\\` + c
}
return `\\` + c
})
}
Expand Down

0 comments on commit da82bd7

Please sign in to comment.