Little bugfix for PGP/INLINE: Make it working again by stop calling non existing method
Bugfix for PGP/MIME: Make it compatible to RFC 3156 (MIME Security with OpenPGP) when using mails with attachments
This commit is contained in:
parent
c022a2fe9d
commit
7934dc00db
|
@ -109,14 +109,26 @@ def encrypt_all_payloads_inline( message, gpg_to_cmdline ):
|
||||||
|
|
||||||
for payload in message.get_payload():
|
for payload in message.get_payload():
|
||||||
if( type( payload.get_payload() ) == list ):
|
if( type( payload.get_payload() ) == list ):
|
||||||
encrypted_payloads.extend( encrypt_all_payloads( payload, gpg_to_cmdline ) )
|
encrypted_payloads.extend( encrypt_all_payloads_inline( payload, gpg_to_cmdline ) )
|
||||||
else:
|
else:
|
||||||
encrypted_payloads.append( encrypt_payload( payload, gpg_to_cmdline ) )
|
encrypted_payloads.append( encrypt_payload( payload, gpg_to_cmdline ) )
|
||||||
return encrypted_payloads
|
return encrypted_payloads
|
||||||
|
|
||||||
|
def generate_attachment_pgp(message, submsg = None):
|
||||||
|
if submsg == None:
|
||||||
|
submsg = email.message.Message()
|
||||||
|
submsg.set_type("multipart/mixed")
|
||||||
|
submsg.set_param('inline', "", 'Content-Disposition' )
|
||||||
|
|
||||||
|
for payload in message.get_payload():
|
||||||
|
if( type( payload.get_payload() ) == list ):
|
||||||
|
submsg.attach(generate_attachment_pgp(payload, submsg))
|
||||||
|
else:
|
||||||
|
submsg.attach(payload)
|
||||||
|
return submsg
|
||||||
|
|
||||||
def encrypt_all_payloads_attachment_style( message, gpg_to_cmdline ):
|
def encrypt_all_payloads_attachment_style( message, gpg_to_cmdline ):
|
||||||
encrypted_payloads = list()
|
encrypted_payloads = list()
|
||||||
if type( message.get_payload() ) == str:
|
|
||||||
# Convert a plain text email into PGP/MIME attachment style. Modeled after enigmail.
|
# Convert a plain text email into PGP/MIME attachment style. Modeled after enigmail.
|
||||||
submsg1 = email.message.Message()
|
submsg1 = email.message.Message()
|
||||||
submsg1.set_payload("Version: 1\n")
|
submsg1.set_payload("Version: 1\n")
|
||||||
|
@ -130,10 +142,14 @@ def encrypt_all_payloads_attachment_style( message, gpg_to_cmdline ):
|
||||||
submsg2.set_param('inline', "", 'Content-Disposition' )
|
submsg2.set_param('inline', "", 'Content-Disposition' )
|
||||||
submsg2.set_param('filename', "encrypted.asc", 'Content-Disposition' )
|
submsg2.set_param('filename', "encrypted.asc", 'Content-Disposition' )
|
||||||
|
|
||||||
|
if type ( message.get_payload() ) == str:
|
||||||
# WTF! It seems to swallow the first line. Not sure why. Perhaps
|
# WTF! It seems to swallow the first line. Not sure why. Perhaps
|
||||||
# it's skipping an imaginary blank line someplace. (ie skipping a header)
|
# it's skipping an imaginary blank line someplace. (ie skipping a header)
|
||||||
# Workaround it here by prepending a blank line.
|
# Workaround it here by prepending a blank line.
|
||||||
|
# This happens only on text only messages.
|
||||||
submsg2.set_payload("\n" + message.get_payload())
|
submsg2.set_payload("\n" + message.get_payload())
|
||||||
|
else:
|
||||||
|
submsg2.set_payload(generate_attachment_pgp(message).as_string())
|
||||||
|
|
||||||
message.preamble = "This is an OpenPGP/MIME encrypted message (RFC 2440 and 3156)"
|
message.preamble = "This is an OpenPGP/MIME encrypted message (RFC 2440 and 3156)"
|
||||||
|
|
||||||
|
@ -150,13 +166,6 @@ def encrypt_all_payloads_attachment_style( message, gpg_to_cmdline ):
|
||||||
|
|
||||||
return [ submsg1, encrypt_payload(submsg2, gpg_to_cmdline) ]
|
return [ submsg1, encrypt_payload(submsg2, gpg_to_cmdline) ]
|
||||||
|
|
||||||
for payload in message.get_payload():
|
|
||||||
if( type( payload.get_payload() ) == list ):
|
|
||||||
encrypted_payloads.extend( encrypt_all_payloads(payload, gpg_to_cmdline) )
|
|
||||||
else:
|
|
||||||
encrypted_payloads.append( encrypt_payload(payload, gpg_to_cmdline) )
|
|
||||||
return encrypted_payloads
|
|
||||||
|
|
||||||
# This method is not referenced
|
# This method is not referenced
|
||||||
def get_msg( message ):
|
def get_msg( message ):
|
||||||
if not message.is_multipart():
|
if not message.is_multipart():
|
||||||
|
|
Loading…
Reference in New Issue