Allow additional parameters after the address in smtp.connection.parasePath. v1.0.0
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 18 Dec 2016 20:26:51 +0000 (15:26 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 18 Dec 2016 20:26:51 +0000 (15:26 -0500)
smtp/conn.go
smtp/conn_test.go

index 0eb3bc9b8472be12f5acfa143590f55730325f15..a8a9a1fc880f699d8c5a2938d0d8b645ac316fc1 100644 (file)
@@ -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() {
index 0fa5bb6acc21347507cbea54f2c7b541e329588b..9eefd65fba382ce902290bf141c399985969c01c 100644 (file)
@@ -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:<sender>", 501, nil},
-               {"MAIL FROM:<sender@foo.com>", 250, nil},
+               {"MAIL FROM:<sender@foo.com> SIZE=2163", 250, nil},
                {"RCPT TO:<banned.net>", 501, nil},
                {"QUIT", 221, nil},
        })