mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/tglx/remail.git
synced 2024-11-24 21:32:39 +01:00
remail/mail: Sanitize incoming headers
Remove CR/LF leftovers which might be in incoming headers before setting them. Happens when handling the weird GPG Outlook attachments. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
dac7c0af8d
commit
8ada1c09b3
1 changed files with 5 additions and 0 deletions
|
@ -197,11 +197,16 @@ def msg_force_msg_id(msg, name):
|
|||
id = make_msgid(name.split('@')[0])
|
||||
msg_set_header(msg, 'Message-ID', id)
|
||||
|
||||
re_rmlfcr = re.compile('[\r\n]')
|
||||
|
||||
def msg_set_header(msg, hdr, txt):
|
||||
'''
|
||||
Set new or replace a message header
|
||||
'''
|
||||
# Sanitize the header first. Broken Outlook GPG payloads
|
||||
# come with wreckaged headers.
|
||||
txt = re_rmlfcr.sub(' ', txt)
|
||||
|
||||
for k in msg.keys():
|
||||
if hdr.lower() == k.lower():
|
||||
msg.replace_header(k, txt)
|
||||
|
|
Loading…
Reference in a new issue