From 56e0c849b2e3005ce7b5d51cbfc4e5578da79f61 Mon Sep 17 00:00:00 2001 From: Dustin Pianalto Date: Tue, 2 Jun 2020 19:16:56 -0800 Subject: [PATCH] Fix bug with shellquote --- djpianalto.com/goff/exts/tags.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/djpianalto.com/goff/exts/tags.go b/djpianalto.com/goff/exts/tags.go index 293222d..435a28c 100644 --- a/djpianalto.com/goff/exts/tags.go +++ b/djpianalto.com/goff/exts/tags.go @@ -1,25 +1,30 @@ package exts import ( - "djpianalto.com/goff/djpianalto.com/goff/utils" "errors" "fmt" - "github.com/dustinpianalto/disgoman" - "github.com/kballard/go-shellquote" "log" "strings" + + "djpianalto.com/goff/djpianalto.com/goff/utils" + "github.com/dustinpianalto/disgoman" + "github.com/kballard/go-shellquote" ) func addTagCommand(ctx disgoman.Context, args []string) { if len(args) >= 1 { args, err := shellquote.Split(strings.Join(args, " ")) if err != nil { - ctx.ErrorChannel <- disgoman.CommandError{ - Context: ctx, - Message: "", - Error: err, + if strings.Contains(err.Error(), "Unterminated") { + args = strings.SplitN(strings.Join(args, " "), " ", 2) + } else { + ctx.ErrorChannel <- disgoman.CommandError{ + Context: ctx, + Message: "", + Error: err, + } + return } - return } queryString := `SELECT tags.id, tags.tag, tags.content from tags WHERE tags.guild_id = $1