From 99d3146f122ee009691bb1727f8145b329199415 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Mon, 29 Aug 2022 15:15:35 -0400 Subject: Force CRLF lineseps only right before sending via smtp We could be sending the patches via a web endpoint, for which we don't need to force CRLF line endings. Convert into CRLF only immediately before sending the message out via smtp. Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index 4296b10..8203a90 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -2911,8 +2911,6 @@ def send_mail(smtp: Union[smtplib.SMTP, smtplib.SMTP_SSL, None], msgs: Sequence[ maxheaderlen = 120 emldata = msg.as_string(maxheaderlen=maxheaderlen) - # Force compliant eols - emldata = re.sub(r'\r\n|\n|\r(?!\n)', '\r\n', emldata) bdata = emldata.encode() if patatt_sign: import patatt @@ -2969,6 +2967,8 @@ def send_mail(smtp: Union[smtplib.SMTP, smtplib.SMTP_SSL, None], msgs: Sequence[ if smtp: sent = 0 for destaddrs, bdata in tosend: + # Force compliant eols + bdata = re.sub(rb'\r\n|\n|\r(?!\n)', b'\r\n', bdata) smtp.sendmail(fromaddr, destaddrs, bdata) sent += 1 return sent -- cgit v1.2.3