From 2cee74a08be328e8ace7a47f91369b58e19d6739 Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Fri, 16 Jun 2023 23:29:09 +0200 Subject: [PATCH] remail: Remove unused functions and debug leftovers Spring cleaning. Signed-off-by: Thomas Gleixner --- remail/mail.py | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/remail/mail.py b/remail/mail.py index d9efe68..aae8813 100644 --- a/remail/mail.py +++ b/remail/mail.py @@ -186,21 +186,8 @@ def decode_addrs(hdr): addrs.append(addr) return addrs -def decode_from(msg): - ''' - Decode the From header and return it as the topmost element - ''' - addrs = decode_addrs(str(msg['From'])) - return addrs.get_first() - re_noquote = re.compile('[a-zA-Z0-9_\- ]+') -def encode_hdr(txt): - try: - return txt.encode('ascii').decode() - except: - txt = txt.encode('UTF-8').decode() - def encode_addr(fulladdr): try: name, addr = fulladdr.split('<', 1) @@ -321,41 +308,6 @@ def msg_set_gpg_payload(msg, encpl, bseed, addpgp=False): 'multipart/encrypted; protocol="application/pgp-encrypted";boundary="%s"' % (boundary)) msg_set_header(msg, 'Content-Disposition', 'inline') -def msg_strip_signature(msg): - ''' - Strip signature from msg for now. The formats are horribly different - and proper encrypted mails are signed as part of the encryption. - ''' - ct = msg.get_content_type() - if ct != 'multipart/signed': - return msg - - boundary = msg.get_boundary(None) - payload = msg.get_payload() - stripped = False - - for m in payload: - if m.get_content_type() == 'application/pgp-signature': - payload.remove(m) - stripped = True - - # If no signature found return unmodified msg - if not stripped: - return - - if len(payload) == 1: - # If the remaining message is only a single item set it as payload - msg_set_payload(msg, payload[0]) - else: - # Recreate the multipart message - content = 'Content-type: multipart/mixed; boundary="%s"\n\n' % boundary - for m in payload: - content += '--%s\n' % boundary - content += m.as_string() - content += '\n' - content += '--%s\n' % boundary - msg_set_payload(msg, msg_from_string(content)) - def msg_strip_html(msg): ''' Strip html from msg @@ -461,7 +413,6 @@ def msg_handle_multimix(msg): for payload in payloads: try: ct = payload.get_content_type() - print(ct) if ct == 'application/pgp-encrypted': gpgpl += 1 continue