diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-11-17 20:43:47 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-11-17 20:43:47 +0100 |
| commit | a1469efbdd141a26696fdef392334dc337b4d924 (patch) | |
| tree | dc5ba3edfa0cef66ce34aefa3790b4526047bcdc /pkg/email/parser.go | |
| parent | 00f6ff581c6a4296baf3271e9114cc3a18da93e6 (diff) | |
pkg/email: unsplit arguments for test command
Diffstat (limited to 'pkg/email/parser.go')
| -rw-r--r-- | pkg/email/parser.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/pkg/email/parser.go b/pkg/email/parser.go index 275403960..cbcdc723d 100644 --- a/pkg/email/parser.go +++ b/pkg/email/parser.go @@ -184,9 +184,31 @@ func extractCommand(body []byte) (cmd, args string) { } split := strings.Split(cmdLine, " ") cmd = split[0] + var aargs []string if len(split) > 1 { - args = strings.TrimSpace(strings.Join(split[1:], " ")) + aargs = split[1:] + } + // Text emails are split at 80 columns are the transformation is irrevesible. + // Try to restore args for some commands that don't have spaces in args. + want := 0 + switch cmd { + case "test:": + want = 2 + case "test_5_arg_cmd": + want = 5 + } + for pos := cmdPos + cmdEnd + 1; len(aargs) < want && pos < len(body); { + lineEnd := bytes.IndexByte(body[pos:], '\n') + if lineEnd == -1 { + lineEnd = len(body) - pos + } + line := strings.TrimSpace(string(body[pos : pos+lineEnd])) + if line != "" { + aargs = append(aargs, strings.Split(line, " ")...) + } + pos += lineEnd + 1 } + args = strings.TrimSpace(strings.Join(aargs, " ")) return } |
