mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/tglx/remail.git
synced 2024-11-22 04:12:38 +01:00
remail/mail: Handle dwmw2s magic evo plugin
dwmw2's evolution plugin which seems to workaround ms-exchange oddities has another interesting format not handled by remail yet: multipart/mixed with: - empty text/plain section - application/pgp-encrypted - application/octed-stream Check for this with at least some sanity checks and morph it into a regular multipart/encrypted message so decrypt can handle it without adding more mess to that part. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
76c07f6d49
commit
7e4cace1e2
1 changed files with 53 additions and 0 deletions
|
@ -402,6 +402,56 @@ def msg_sanitize_outlook(msg):
|
||||||
# code.
|
# code.
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
def msg_handle_multimix(msg):
|
||||||
|
'''
|
||||||
|
Magic format used by dwmw2's devolution plugin to prevent
|
||||||
|
exchange from wreckaging mail. It's kinda valid, but sigh...
|
||||||
|
|
||||||
|
Multipart mixed message with:
|
||||||
|
- empty text/plain
|
||||||
|
- application/pgp-encrypted
|
||||||
|
- application/octed-stream
|
||||||
|
|
||||||
|
Make it look like a sane PGP application/encrypted mail
|
||||||
|
'''
|
||||||
|
ct = msg.get_content_type()
|
||||||
|
if ct != 'multipart/mixed':
|
||||||
|
return
|
||||||
|
|
||||||
|
fnames = ['msg.asc', 'encrypted.asc']
|
||||||
|
gpgpl = 0
|
||||||
|
otherpl = []
|
||||||
|
|
||||||
|
payloads = msg.get_payload()
|
||||||
|
for payload in payloads:
|
||||||
|
try:
|
||||||
|
ct = payload.get_content_type()
|
||||||
|
print(ct)
|
||||||
|
if ct == 'application/pgp-encrypted':
|
||||||
|
gpgpl += 1
|
||||||
|
continue
|
||||||
|
elif ct == 'application/octet-stream':
|
||||||
|
fname = payload.get_filename(None)
|
||||||
|
if gpgpl == 1 and fname in fnames:
|
||||||
|
gpgpl += 1
|
||||||
|
continue
|
||||||
|
# None of the above. Mark it as other
|
||||||
|
otherpl.append(payload)
|
||||||
|
except:
|
||||||
|
# Ignore fails here. This is all best effort
|
||||||
|
# guesswork.
|
||||||
|
pass
|
||||||
|
|
||||||
|
if gpgpl != 2:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Remove the irrelevant payload parts
|
||||||
|
for pl in otherpl:
|
||||||
|
payloads.remove(pl)
|
||||||
|
# Fixup the message type so decrypt knows what to do with it
|
||||||
|
msg.set_type('multipart/encrypted')
|
||||||
|
msg.set_param('protocol', 'application/pgp-encrypted')
|
||||||
|
|
||||||
def decode_base64(msg):
|
def decode_base64(msg):
|
||||||
#
|
#
|
||||||
# Decode base64 encoded text/plain sections
|
# Decode base64 encoded text/plain sections
|
||||||
|
@ -436,6 +486,9 @@ def msg_sanitize_incoming(msg):
|
||||||
# Strip html multipart first
|
# Strip html multipart first
|
||||||
msg_strip_html(msg)
|
msg_strip_html(msg)
|
||||||
|
|
||||||
|
# Handle multipart/mixed
|
||||||
|
msg_handle_multimix(msg)
|
||||||
|
|
||||||
# Sanitize outlook crappola
|
# Sanitize outlook crappola
|
||||||
msg_sanitize_outlook(msg)
|
msg_sanitize_outlook(msg)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue