From 6a745eaa96a8f63c528d1b9361d5d320e670f0cd Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Sun, 7 Dec 2008 23:44:51 -0700 Subject: [PATCH] Fix for Ticket #4221. Fix stripping attachments when saving to sent-mail folder when attaching the PGP public key. --- imp/docs/CHANGES | 2 ++ imp/lib/Compose.php | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index c3475cfc7..d7061f07b 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,8 @@ v5.0-cvs -------- +[mms] Fix stripping attachments when saving to sent-mail folder when attaching + the PGP public key (Bug #4221). [mms] Removed Special Characters menu. [mms] Add 'undelete' to Other Actions menu (Bug #7496) (DIMP). [mms] PGP functions now work in DIMP (Bug #5388). diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index edb6bfabf..6f44368d3 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -556,15 +556,17 @@ class IMP_Compose if (($save_attach == 'never') || ((strpos($save_attach, 'prompt') === 0) && empty($opts['save_attachments']))) { - foreach (array_keys($this->getAttachments()) as $i) { - $oldPart = $mime_message->getPart(++$i); - if ($oldPart !== false) { - $replace_part = new Horde_Mime_Part(); - $replace_part->setType('text/plain'); - $replace_part->setCharset($charset); - $replace_part->setContents('[' . _("Attachment stripped: Original attachment type") . ': "' . $oldPart->getType() . '", ' . _("name") . ': "' . $oldPart->getName(true) . '"]', '8bit'); - $mime_message->alterPart($i, $replace_part); + $mime_message->buildMimeIds(); + for ($i = 2; ; ++$i) { + if (!($oldPart = $mime_message->getPart($i))) { + break; } + + $replace_part = new Horde_Mime_Part(); + $replace_part->setType('text/plain'); + $replace_part->setCharset($charset); + $replace_part->setContents('[' . _("Attachment stripped: Original attachment type") . ': "' . $oldPart->getType() . '", ' . _("name") . ': "' . $oldPart->getName(true) . '"]', '8bit'); + $mime_message->alterPart($i, $replace_part); } } -- 2.11.0