From a7bbe24b6f474dba5ca701413c268fe192e44346 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 22 Nov 2017 15:57:46 +0100 Subject: dashboard/app: strip quotes from commit titles There is probably no way to stop people doing this. Though, we never mention that this is allowed syntax... --- dashboard/app/fix_test.go | 2 +- dashboard/app/reporting.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dashboard/app/fix_test.go b/dashboard/app/fix_test.go index a12674764..23023bb2a 100644 --- a/dashboard/app/fix_test.go +++ b/dashboard/app/fix_test.go @@ -153,7 +153,7 @@ func TestFixedByTwoCommits(t *testing.T) { cmd := &dashapi.BugUpdate{ ID: rep.ID, Status: dashapi.BugStatusOpen, - FixCommits: []string{"bar: prepare for fixing", "foo: fix the crash"}, + FixCommits: []string{"bar: prepare for fixing", "\"foo: fix the crash\""}, } reply := new(dashapi.BugUpdateReply) c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply)) diff --git a/dashboard/app/reporting.go b/dashboard/app/reporting.go index bfb8a02d9..9180c14ad 100644 --- a/dashboard/app/reporting.go +++ b/dashboard/app/reporting.go @@ -253,6 +253,15 @@ func incomingCommand(c context.Context, cmd *dashapi.BugUpdate) (bool, string, e } func incomingCommandImpl(c context.Context, cmd *dashapi.BugUpdate) (bool, string, error) { + for i, com := range cmd.FixCommits { + if len(com) >= 2 && com[0] == '"' && com[len(com)-1] == '"' { + com = com[1 : len(com)-1] + cmd.FixCommits[i] = com + } + if len(com) < 3 { + return false, fmt.Sprintf("bad commit title: %q", com), nil + } + } bug, bugKey, err := findBugByReportingID(c, cmd.ID) if err != nil { return false, internalError, err @@ -421,9 +430,6 @@ func incomingCommandTx(c context.Context, now time.Time, cmd *dashapi.BugUpdate, if !same { commits := make([]string, 0, len(m)) for com := range m { - if len(com) < 3 { - return false, fmt.Sprintf("bad commit title: %q", com), nil - } commits = append(commits, com) } sort.Strings(commits) -- cgit mrf-deployment