Unify detection of pgp/mime message part

pull/297/head
Thomas Bruederli 9 years ago
parent f189d72943
commit f7f75ff7d1

@ -3481,6 +3481,7 @@ function rcube_webmail()
} }
}).catch(function(err) { }).catch(function(err) {
console.error(err); console.error(err);
console.log(options);
}); });
} }
}; };

@ -483,6 +483,28 @@ class rcube_message
return false; return false;
} }
/**
* In a multipart/encrypted encrypted message,
* find the encrypted message payload part.
*
* @return rcube_message_part
*/
public function get_multipart_encrypted_part()
{
foreach ($this->mime_parts as $mime_id => $mpart) {
if ($mpart->mimetype == 'multipart/encrypted') {
$this->pgp_mime = true;
}
if ($this->pgp_mime && ($mpart->mimetype == 'application/octet-stream' ||
(!empty($mpart->filename) && $mpart->filename != 'version.txt'))) {
$this->encrypted_part = $mime_id;
return $mpart;
}
}
return false;
}
/** /**
* Read the message structure returend by the IMAP server * Read the message structure returend by the IMAP server
* and build flat lists of content parts and attachments * and build flat lists of content parts and attachments

@ -782,15 +782,13 @@ function rcmail_prepare_message_body()
foreach ($MESSAGE->parts as $part) { foreach ($MESSAGE->parts as $part) {
if ($part->realtype == 'multipart/encrypted') { if ($part->realtype == 'multipart/encrypted') {
// find the encrypted message payload part // find the encrypted message payload part
foreach ($MESSAGE->mime_parts as $mime_id => $mpart) { if ($pgp_mime_part = $MESSAGE->get_multipart_encrypted_part()) {
if ($mpart->mimetype == 'application/octet-stream' || !empty($mpart->filename)) { $RCMAIL->output->set_env('pgp_mime_message', array(
$RCMAIL->output->set_env('pgp_mime_message', array( '_mbox' => $RCMAIL->storage->get_folder(),
'_mbox' => $RCMAIL->storage->get_folder(), '_uid' => $MESSAGE->uid, '_part' => $mime_id, '_uid' => $MESSAGE->uid,
)); '_part' => $pgp_mime_part->mime_id,
$RCMAIL->output->set_env('compose_mode', $compose_mode); ));
$MESSAGE->pgp_mime = true; $RCMAIL->output->set_env('compose_mode', $compose_mode);
break;
}
} }
continue; continue;
} }
@ -1271,6 +1269,11 @@ function rcmail_write_compose_attachments(&$message, $bodyIsHtml)
continue; continue;
} }
// skip version.txt parts of multipart/encrypted messages
if ($message->pgp_mime && $part->mimetype == 'application/pgp-encrypted' && $part->filename == 'version.txt') {
continue;
}
// skip message/rfc822 attachments on forwards (#1489214) // skip message/rfc822 attachments on forwards (#1489214)
// Thunderbird when forwarding in inline mode displays such attachments // Thunderbird when forwarding in inline mode displays such attachments
// and skips any attachments from inside of such part, this however // and skips any attachments from inside of such part, this however

@ -1193,18 +1193,11 @@ function rcmail_message_body($attrib)
// unsupported (e.g. encrypted) // unsupported (e.g. encrypted)
if ($part->realtype) { if ($part->realtype) {
if ($part->realtype == 'multipart/encrypted' || $part->realtype == 'application/pkcs7-mime') { if ($part->realtype == 'multipart/encrypted' || $part->realtype == 'application/pkcs7-mime') {
if (!empty($_SESSION['browser_caps']['pgpmime']) && $part->realtype == 'multipart/encrypted') { if (!empty($_SESSION['browser_caps']['pgpmime']) && ($pgp_mime_part = $MESSAGE->get_multipart_encrypted_part())) {
// find the encrypted message payload part $out .= html::span('part-notice', $RCMAIL->gettext('externalmessagedecryption'));
foreach ($MESSAGE->mime_parts as $mime_id => $mpart) { $OUTPUT->set_env('pgp_mime_part', $pgp_mime_part->mime_id);
if ($mpart->mimetype == 'application/octet-stream' || !empty($mpart->filename)) { $OUTPUT->set_env('pgp_mime_container', '#' . $attrib['id']);
$out .= html::span('part-notice', $RCMAIL->gettext('externalmessagedecryption')); $OUTPUT->add_label('loadingdata');
$OUTPUT->set_env('pgp_mime_part', $mime_id);
$OUTPUT->set_env('pgp_mime_container', '#' . $attrib['id']);
$OUTPUT->add_label('loadingdata');
$MESSAGE->encrypted_part = $mime_id;
break;
}
}
} }
if (!$MESSAGE->encrypted_part) { if (!$MESSAGE->encrypted_part) {

Loading…
Cancel
Save