From c3b13e47f7fe99f3381726fd11dd317cbcc6622e Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Sun, 18 Jun 2023 18:23:36 +0200 Subject: [PATCH] remail: Simplify msg_set_header() Signed-off-by: Thomas Gleixner --- remail/mail.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/remail/mail.py b/remail/mail.py index 440eecc..4ec3eaa 100644 --- a/remail/mail.py +++ b/remail/mail.py @@ -195,12 +195,10 @@ def msg_set_header(msg, hdr, txt): # come with wreckaged headers. txt = re_rmlfcr.sub(' ', txt) - for k in msg.keys(): - if hdr.lower() == k.lower(): - msg.replace_header(k, txt) - return - # Not found set new - msg[hdr] = txt + if msg.get(hdr): + msg.replace_header(hdr, txt) + else: + msg[hdr] = txt payload_valid_mime_headers = [ 'Content-Description',