From 69423a1d41ce792ddad1c5636b61df7cb2e91440 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 13 May 2019 14:15:14 +0200 Subject: pkg/email: allow commands in subject Several users attempted this and there does not seem to be any reason to not allow this. So parse out command from subject as well. --- pkg/email/parser_test.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'pkg/email/parser_test.go') diff --git a/pkg/email/parser_test.go b/pkg/email/parser_test.go index 0085adeb9..ba027f8e7 100644 --- a/pkg/email/parser_test.go +++ b/pkg/email/parser_test.go @@ -15,13 +15,13 @@ import ( func TestExtractCommand(t *testing.T) { for i, test := range extractCommandTests { t.Run(fmt.Sprint(i), func(t *testing.T) { - cmd, str, args := extractCommand([]byte(test.body)) + cmd, str, args := extractCommand(test.body) if cmd != test.cmd || str != test.str || !reflect.DeepEqual(args, test.args) { t.Logf("expect: %v %q %q", test.cmd, test.str, test.args) t.Logf("got : %v %q %q", cmd, str, args) t.Fail() } - cmd, str, args = extractCommand([]byte(strings.Replace(test.body, "\n", "\r\n", -1))) + cmd, str, args = extractCommand(strings.Replace(test.body, "\n", "\r\n", -1)) if cmd != test.cmd || str != test.str || !reflect.DeepEqual(args, test.args) { t.Logf("expect: %v %q %q", test.cmd, test.str, test.args) t.Logf("got : %v %q %q", cmd, str, args) @@ -656,4 +656,23 @@ When freeing a lockf struct that already is part of a linked list, make sure to CommandStr: "fix:", CommandArgs: "When freeing a lockf struct that already is part of a linked list, make sure to", }}, + + {`Date: Sun, 7 May 2017 19:54:00 -0700 +Message-ID: <123> +Subject: #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git master +From: bob@example.com +To: syzbot + +nothing to see here`, + Email{ + BugID: "4564456", + MessageID: "<123>", + Subject: "#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git master", + From: "", + Cc: []string{"bob@example.com"}, + Body: `nothing to see here`, + Command: CmdTest, + CommandStr: "test:", + CommandArgs: "git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git master", + }}, } -- cgit mrf-deployment