66__author__ = 'Simon Robinson'
77__copyright__ = 'Copyright (c) 2022 Simon Robinson'
88__license__ = 'Apache 2.0'
9- __version__ = '2022-12-05 ' # ISO 8601 (YYYY-MM-DD)
9+ __version__ = '2022-12-14 ' # ISO 8601 (YYYY-MM-DD)
1010
1111import argparse
1212import base64
@@ -1075,7 +1075,7 @@ def process_data(self, byte_data, censor_server_log=False):
10751075 self .authentication_tag = match .group ('tag' )
10761076 if len (split_flags ) > 1 :
10771077 username , password = OAuth2Helper .decode_credentials (' ' .join (split_flags [1 :]))
1078- self .authenticate_connection (username , password , 'authenticate' )
1078+ self .authenticate_connection (username , password , command = self . authentication_command )
10791079 else :
10801080 self .awaiting_credentials = True
10811081 self .censor_next_log = True
@@ -1094,8 +1094,7 @@ def authenticate_connection(self, username, password, command='login'):
10941094 # send authentication command to server (response checked in ServerConnection)
10951095 # note: we only support single-trip authentication (SASL) without checking server capabilities - improve?
10961096 super ().process_data (b'%s AUTHENTICATE XOAUTH2 ' % self .authentication_tag .encode ('utf-8' ))
1097- super ().process_data (OAuth2Helper .encode_oauth2_string (result ), censor_server_log = True )
1098- super ().process_data (b'\r \n ' )
1097+ super ().process_data (b'%s\r \n ' % OAuth2Helper .encode_oauth2_string (result ), censor_server_log = True )
10991098
11001099 # because get_oauth2_credentials blocks, the server could have disconnected, and may no-longer exist
11011100 if self .server_connection :
@@ -1363,7 +1362,7 @@ def process_data(self, byte_data):
13631362
13641363 def send (self , byte_data , censor_log = False ):
13651364 if not self .client_connection .authenticated : # after authentication these are identical to server-side logs
1366- Log .debug (self .info_string (), ' -->' , CENSOR_MESSAGE if censor_log else byte_data )
1365+ Log .debug (self .info_string (), ' -->' , b'%s \r \n ' % CENSOR_MESSAGE if censor_log else byte_data )
13671366 return super ().send (byte_data )
13681367
13691368 def handle_error (self ):
@@ -1587,8 +1586,7 @@ def process_data(self, byte_data):
15871586 if success :
15881587 self .client_connection .connection_state = SMTPOAuth2ClientConnection .STATE .XOAUTH2_CREDENTIALS_SENT
15891588 self .authenticated_username = self .username
1590- self .send (OAuth2Helper .encode_oauth2_string (result ), censor_log = True )
1591- self .send (b'\r \n ' )
1589+ self .send (b'%s\r \n ' % OAuth2Helper .encode_oauth2_string (result ), censor_log = True )
15921590
15931591 self .username = None
15941592 self .password = None
0 commit comments