aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/email
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2021-03-09 15:43:49 +0100
committerDmitry Vyukov <dvyukov@google.com>2021-03-09 17:06:47 +0100
commit26967e354e030f6a022b7a60a7c9899ec25923aa (patch)
treee99a85ff348780953fd64ce86b8a767cc62c6170 /pkg/email
parentb25a4606f025c0705910748510b9c763b56e37a5 (diff)
pkg/email: strip \t in test command args
There was a precedent of using: syz fix: repo \t commit This was rejected as error. Support \t between tokens.
Diffstat (limited to 'pkg/email')
-rw-r--r--pkg/email/parser.go9
-rw-r--r--pkg/email/parser_test.go18
2 files changed, 24 insertions, 3 deletions
diff --git a/pkg/email/parser.go b/pkg/email/parser.go
index df7cc4717..d7bf40a0f 100644
--- a/pkg/email/parser.go
+++ b/pkg/email/parser.go
@@ -199,7 +199,7 @@ const commandPrefix = "#syz"
func extractCommand(body string) (cmd Command, str, args string) {
nbody := "\n" + body
cmdPos := -1
- for _, delim := range []string{" ", "-", ":"} {
+ for _, delim := range []string{" ", "\t", "-", ":"} {
cmdPos = strings.Index(nbody, "\n"+commandPrefix+delim)
if cmdPos != -1 {
break
@@ -210,7 +210,7 @@ func extractCommand(body string) (cmd Command, str, args string) {
return
}
cmdPos += len(commandPrefix) + 1
- for cmdPos < len(body) && body[cmdPos] == ' ' {
+ for cmdPos < len(body) && (body[cmdPos] == ' ' || body[cmdPos] == '\t') {
cmdPos++
}
cmdEnd := strings.IndexByte(body[cmdPos:], '\n')
@@ -223,6 +223,9 @@ func extractCommand(body string) (cmd Command, str, args string) {
if cmdEnd1 := strings.IndexByte(body[cmdPos:], ' '); cmdEnd1 != -1 && cmdEnd1 < cmdEnd {
cmdEnd = cmdEnd1
}
+ if cmdEnd1 := strings.IndexByte(body[cmdPos:], '\t'); cmdEnd1 != -1 && cmdEnd1 < cmdEnd {
+ cmdEnd = cmdEnd1
+ }
str = body[cmdPos : cmdPos+cmdEnd]
cmd = strToCmd(str)
// Some email clients split text emails at 80 columns are the transformation is irrevesible.
@@ -274,7 +277,7 @@ func extractArgsTokens(body string, num int) string {
if lineEnd == -1 {
lineEnd = len(body) - pos
}
- line := strings.TrimSpace(body[pos : pos+lineEnd])
+ line := strings.TrimSpace(strings.Replace(body[pos:pos+lineEnd], "\t", " ", -1))
for {
line1 := strings.Replace(line, " ", " ", -1)
if line == line1 {
diff --git a/pkg/email/parser_test.go b/pkg/email/parser_test.go
index f093a0d22..88b7b4ad9 100644
--- a/pkg/email/parser_test.go
+++ b/pkg/email/parser_test.go
@@ -221,6 +221,18 @@ locking/core
args: "git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking/core",
},
{
+ body: `#syz test: repo commit`,
+ cmd: CmdTest,
+ str: "test:",
+ args: "repo commit",
+ },
+ {
+ body: `#syz test: repo commit`,
+ cmd: CmdTest,
+ str: "test:",
+ args: "repo commit",
+ },
+ {
body: `
#syz test_5_arg_cmd arg1
@@ -234,6 +246,12 @@ arg5
args: "arg1 arg2 arg3 arg4 arg5",
},
{
+ body: `#syz test_5_arg_cmd arg1 arg2 arg3 arg4 arg5`,
+ cmd: cmdTest5,
+ str: "test_5_arg_cmd",
+ args: "arg1 arg2 arg3 arg4 arg5",
+ },
+ {
body: `
#syz test_5_arg_cmd arg1
arg2`,