Lower-case the addresses in smtp.conn.parsePath. v1.1.1
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 17 Jan 2017 02:21:25 +0000 (21:21 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 17 Jan 2017 02:21:25 +0000 (21:21 -0500)
smtp/conn.go
smtp/conn_test.go

index 1837027f93b806efcf9a6647e0ff43d1df831e64..f8ef4c15c2c1cab905bea2c8fa6901e64f4c196b 100644 (file)
@@ -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() {
index 9eefd65fba382ce902290bf141c399985969c01c..4a9310106328de36ed41e2f11176f5e7ecb8ce5b 100644 (file)
@@ -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:<sender@example.com>", 250, nil},
                {"RcPT tO:<receive@mail.com>", 250, nil},
+               {"RCPT TO:<reject@MAIL.com>", 550, nil},
+               {"RCPT TO:<reject@mail.com>", 550, nil},
                {"DATa", 0, func(t testing.TB, conn *textproto.Conn) {
                        readCodeLine(t, conn, 354)