Skip to content

Commit

Permalink
Fix resuming when message consists entirely of attachment data
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Dec 1, 2014
1 parent b8cf9c7 commit 7548c33
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions imp/lib/Compose.php
Expand Up @@ -465,7 +465,7 @@ public function useTemplate($indices, array $opts = array())
*/
protected function _resumeDraft($indices, $type, $opts)
{
global $injector, $prefs;
global $injector, $notification, $prefs;

$contents_factory = $injector->getInstance('IMP_Factory_Contents');

Expand Down Expand Up @@ -550,22 +550,29 @@ protected function _resumeDraft($indices, $type, $opts)
$mime_message = $contents->getMIMEMessage();

/* Add attachments. */
$parts = array();
if (($mime_message->getPrimaryType() == 'multipart') &&
($mime_message->getType() != 'multipart/alternative')) {
for ($i = 1; ; ++$i) {
if (intval($text_id) == $i) {
continue;
}

if (!($part = $contents->getMimePart($i))) {
if ($part = $contents->getMimePart($i)) {
$parts[] = $part;
} else {
break;
}
}
} elseif ($mime_message->getDisposition() == 'attachment') {
$parts[] = $contents->getMimePart('1');
}

try {
$this->addAttachmentFromPart($part);
} catch (IMP_Compose_Exception $e) {
$GLOBALS['notification']->push($e, 'horde.warning');
}
foreach ($parts as $val) {
try {
$this->addAttachmentFromPart($val);
} catch (IMP_Compose_Exception $e) {
$notification->push($e, 'horde.warning');
}
}

Expand Down

0 comments on commit 7548c33

Please sign in to comment.