[Remail] [patch v2 01/11] remail: Remove unused functions and debug leftovers

Thomas Gleixner tglx at linutronix.de
Sun Jun 18 22:13:42 CEST 2023


Spring cleaning.

Signed-off-by: Thomas Gleixner <tglx at linutronix.de>
---
 remail/mail.py |   49 -------------------------------------------------
 1 file changed, 49 deletions(-)

--- a/remail/mail.py
+++ b/remail/mail.py
@@ -186,21 +186,8 @@ re_compress_space = re.compile('\s+')
         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 @@ payload_valid_mime_headers = [
                    '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 @@ payload_valid_mime_headers = [
     for payload in payloads:
         try:
             ct = payload.get_content_type()
-            print(ct)
             if ct == 'application/pgp-encrypted':
                 gpgpl += 1
                 continue



More information about the Remail mailing list