From ffa4cb47f3d238643406f7c26e7b866050b99d27 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 18 Dec 2016 15:26:51 -0500 Subject: [PATCH] Allow additional parameters after the address in smtp.connection.parasePath. --- smtp/conn.go | 7 ++++++- smtp/conn_test.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/smtp/conn.go b/smtp/conn.go index 0eb3bc9..a8a9a1f 100644 --- a/smtp/conn.go +++ b/smtp/conn.go @@ -138,7 +138,12 @@ func (conn *connection) parsePath(command string) (string, ReplyLine) { if strings.ToUpper(command) != strings.ToUpper(conn.line[:len(command)]) { return "", ReplyLine{500, "unrecognized command"} } - return conn.line[len(command):], ReplyOK + params := conn.line[len(command):] + idx := strings.Index(params, ">") + if idx == -1 { + return "", ReplyBadSyntax + } + return params[:idx+1], ReplyOK } func (conn *connection) doEHLO() { diff --git a/smtp/conn_test.go b/smtp/conn_test.go index 0fa5bb6..9eefd65 100644 --- a/smtp/conn_test.go +++ b/smtp/conn_test.go @@ -178,7 +178,7 @@ func TestBadAddress(t *testing.T) { runTableTest(t, conn, []requestResponse{ {"EHLO test", 0, func(t testing.TB, conn *textproto.Conn) { conn.ReadResponse(250) }}, {"MAIL FROM:", 501, nil}, - {"MAIL FROM:", 250, nil}, + {"MAIL FROM: SIZE=2163", 250, nil}, {"RCPT TO:", 501, nil}, {"QUIT", 221, nil}, }) -- 2.22.5