From 647ff86b291d76e7060020ba2a561876305bc40b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=9B=BC=E5=BA=9A?= Date: Fri, 16 Aug 2024 15:46:16 +0800 Subject: [PATCH] Support lowercase username and password challenge --- smtp/auth_login.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/smtp/auth_login.go b/smtp/auth_login.go index 7cd5c5d..aa80223 100644 --- a/smtp/auth_login.go +++ b/smtp/auth_login.go @@ -20,13 +20,15 @@ const ( // extension. // // See: https://learn.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-xlogin/. - LoginXUsernameChallenge = "Username:" + LoginXUsernameChallenge = "Username:" + LoginXUsernameLowerChallenge = "username:" // LoginXPasswordChallenge represents the Password Challenge response sent by the SMTP server per the AUTH LOGIN // extension. // // See: https://learn.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-xlogin/. - LoginXPasswordChallenge = "Password:" + LoginXPasswordChallenge = "Password:" + LoginXPasswordLowerChallenge = "password:" // LoginXDraftUsernameChallenge represents the Username Challenge response sent by the SMTP server per the IETF // draft AUTH LOGIN extension. It should be noted this extension is an expired draft which was never formally @@ -76,9 +78,9 @@ func (a *loginAuth) Start(server *ServerInfo) (string, []byte, error) { func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) { if more { switch string(fromServer) { - case LoginXUsernameChallenge, LoginXDraftUsernameChallenge: + case LoginXUsernameChallenge, LoginXUsernameLowerChallenge, LoginXDraftUsernameChallenge: return []byte(a.username), nil - case LoginXPasswordChallenge, LoginXDraftPasswordChallenge: + case LoginXPasswordChallenge, LoginXPasswordLowerChallenge, LoginXDraftPasswordChallenge: return []byte(a.password), nil default: return nil, fmt.Errorf("unexpected server response: %s", string(fromServer))