diff options
author | Michael Muré <batolettre@gmail.com> | 2022-05-01 12:30:55 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2022-05-01 12:31:50 +0200 |
commit | b9991d84b913577a17635b4ca8863d60cda79c42 (patch) | |
tree | d9cb340d571b685c7458c2f3e1fc2f8b1b0664f5 /commands/ls.go | |
parent | edc8b7589dcf1daad65b0e57488a3b3f86711926 (diff) | |
download | git-bug-b9991d84b913577a17635b4ca8863d60cda79c42.tar.gz git-bug-b9991d84b913577a17635b4ca8863d60cda79c42.zip |
ls: fix incorrect query parsing with quotes escaped by the shell
Diffstat (limited to 'commands/ls.go')
-rw-r--r-- | commands/ls.go | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/commands/ls.go b/commands/ls.go index 909e25a87..da5ea8ce5 100644 --- a/commands/ls.go +++ b/commands/ls.go @@ -103,13 +103,9 @@ func runLs(env *Env, opts lsOptions, args []string) error { var err error if len(args) >= 1 { - // either the shell or cobra remove the quotes, we need them back for the parsing - for i, arg := range args { - if strings.Contains(arg, " ") { - args[i] = fmt.Sprintf("\"%s\"", arg) - } - } - assembled := strings.Join(args, " ") + // either the shell or cobra remove the quotes, we need them back for the query parsing + assembled := repairQuery(args) + q, err = query.Parse(assembled) if err != nil { return err @@ -153,6 +149,19 @@ func runLs(env *Env, opts lsOptions, args []string) error { } } +func repairQuery(args []string) string { + for i, arg := range args { + split := strings.Split(arg, ":") + for j, s := range split { + if strings.Contains(s, " ") { + split[j] = fmt.Sprintf("\"%s\"", s) + } + } + args[i] = strings.Join(split, ":") + } + return strings.Join(args, " ") +} + type JSONBugExcerpt struct { Id string `json:"id"` HumanId string `json:"human_id"` |