From 1e462588041aca4c222943b4259802ca8410fce1 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 16 Jan 2017 21:21:25 -0500 Subject: [PATCH] Lower-case the addresses in smtp.conn.parsePath. --- smtp/conn.go | 2 +- smtp/conn_test.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/smtp/conn.go b/smtp/conn.go index 1837027..f8ef4c1 100644 --- a/smtp/conn.go +++ b/smtp/conn.go @@ -145,7 +145,7 @@ func (conn *connection) parsePath(command string) (string, ReplyLine) { if idx == -1 { return "", ReplyBadSyntax } - return params[:idx+1], ReplyOK + return strings.ToLower(params[:idx+1]), ReplyOK } func (conn *connection) doEHLO() { diff --git a/smtp/conn_test.go b/smtp/conn_test.go index 9eefd65..4a93101 100644 --- a/smtp/conn_test.go +++ b/smtp/conn_test.go @@ -66,7 +66,7 @@ func (s *testServer) Name() string { func (s *testServer) VerifyAddress(addr mail.Address) ReplyLine { for _, block := range s.blockList { - if block == addr.Address { + if strings.ToLower(block) == addr.Address { return ReplyBadMailbox } } @@ -186,6 +186,7 @@ func TestBadAddress(t *testing.T) { func TestCaseSensitivty(t *testing.T) { s := &testServer{} + s.blockList = []string{"reject@mail.com"} l := runServer(t, s) defer l.Close() @@ -197,6 +198,8 @@ func TestCaseSensitivty(t *testing.T) { {"ehLO test.TEST", 0, func(t testing.TB, conn *textproto.Conn) { conn.ReadResponse(250) }}, {"mail FROM:", 250, nil}, {"RcPT tO:", 250, nil}, + {"RCPT TO:", 550, nil}, + {"RCPT TO:", 550, nil}, {"DATa", 0, func(t testing.TB, conn *textproto.Conn) { readCodeLine(t, conn, 354) -- 2.43.5