fix: replace cr and lf characters with empty string in case of exception

(cherry picked from commit 6310494aa9afb67058b5d0b8d0f4cc8e382357e2)
This commit is contained in:
prssanna 2020-09-08 21:03:25 +05:30 committed by mergify-bot
parent 613bb92d5c
commit be36c532b7

View file

@ -207,7 +207,7 @@ class EMail:
def set_in_reply_to(self, in_reply_to):
"""Used to send the Message-Id of a received email back as In-Reply-To"""
self.msg_root["In-Reply-To"] = in_reply_to.replace("\r", "").replace("\n", "")
self.set_header('In-Reply-To', in_reply_to)
def make(self):
"""build into msg_root"""
@ -234,7 +234,10 @@ class EMail:
if key in self.msg_root:
del self.msg_root[key]
self.msg_root[key] = value
try:
self.msg_root[key] = value
except ValueError:
self.msg_root[key] = sanitize_email_header(value)
def as_string(self):
"""validate, build message and convert to string"""
@ -458,3 +461,6 @@ def get_header(header=None):
})
return email_header
def sanitize_email_header(str):
return str.replace('\r', '').replace('\n', '')