aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/email
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-01-07 14:32:50 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-01-07 14:32:50 +0100
commit7042566e4bdaaec059aea4f53eeefc4f362648cd (patch)
treeceb86810a9148761db939f2ebccd7103319278a5 /pkg/email
parent36860d8b256045601248ecfc0323ac838779e72b (diff)
pkg/email: accept #syz- prefix for commands
Some users spell the command as "#syz-dup:". Support this and few more variations.
Diffstat (limited to 'pkg/email')
-rw-r--r--pkg/email/parser.go15
-rw-r--r--pkg/email/parser_test.go18
-rw-r--r--pkg/email/reply_test.go28
3 files changed, 57 insertions, 4 deletions
diff --git a/pkg/email/parser.go b/pkg/email/parser.go
index 9c37331f7..589598ba2 100644
--- a/pkg/email/parser.go
+++ b/pkg/email/parser.go
@@ -47,8 +47,6 @@ const (
cmdTest5
)
-const commandPrefix = "#syz "
-
var groupsLinkRe = regexp.MustCompile("\nTo view this discussion on the web visit" +
" (https://groups\\.google\\.com/.*?)\\.(?:\r)?\n")
@@ -192,16 +190,25 @@ func CanonicalEmail(email string) string {
return strings.ToLower(addr.Address)
}
+const commandPrefix = "#syz"
+
// extractCommand extracts command to syzbot from email body.
// Commands are of the following form:
// ^#syz cmd args...
func extractCommand(body string) (cmd Command, str, args string) {
- cmdPos := strings.Index("\n"+body, "\n"+commandPrefix)
+ nbody := "\n" + body
+ cmdPos := -1
+ for _, delim := range []string{" ", "-", ":"} {
+ cmdPos = strings.Index(nbody, "\n"+commandPrefix+delim)
+ if cmdPos != -1 {
+ break
+ }
+ }
if cmdPos == -1 {
cmd = CmdNone
return
}
- cmdPos += len(commandPrefix)
+ cmdPos += len(commandPrefix) + 1
for cmdPos < len(body) && body[cmdPos] == ' ' {
cmdPos++
}
diff --git a/pkg/email/parser_test.go b/pkg/email/parser_test.go
index ba027f8e7..f093a0d22 100644
--- a/pkg/email/parser_test.go
+++ b/pkg/email/parser_test.go
@@ -171,6 +171,24 @@ line 2
cmd: CmdNone,
args: "",
},
+ {
+ body: `#syz-fix: bar baz`,
+ cmd: CmdFix,
+ str: "fix:",
+ args: "bar baz",
+ },
+ {
+ body: `#syz-fix bar baz`,
+ cmd: CmdFix,
+ str: "fix",
+ args: "bar baz",
+ },
+ {
+ body: `#syz: fix: bar baz`,
+ cmd: CmdFix,
+ str: "fix:",
+ args: "bar baz",
+ },
// This is unfortunate case when a command is split by email client
// due to 80-column limitation.
{
diff --git a/pkg/email/reply_test.go b/pkg/email/reply_test.go
index 75d2eca09..4e6256ccf 100644
--- a/pkg/email/reply_test.go
+++ b/pkg/email/reply_test.go
@@ -43,6 +43,34 @@ this is reply
`,
},
{
+ email: `
+#syz-fix
+line2
+`,
+ reply: "this is reply",
+ result: `>
+> #syz-fix
+
+this is reply
+
+> line2
+`,
+ },
+ {
+ email: `
+#syz: fix
+line2
+`,
+ reply: "this is reply",
+ result: `>
+> #syz: fix
+
+this is reply
+
+> line2
+`,
+ },
+ {
email: `> line1
> line2
#syz foo