Skip to content

Commit

Permalink
Protect against fatal error if requesting attachment that doesn't exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Dec 6, 2018
1 parent d43deb9 commit 4f73dfd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/Contents.php
Expand Up @@ -802,6 +802,9 @@ public function getSummary($id, $mask = 0)
);

$mime_part = $this->getMIMEPart($id, array('nocontents' => true));
if (empty($mime_part)) {
throw new IMP_Exception('MIME Part not found.');
}
$mime_type = $mime_part->getType();

/* If this is an attachment that has no specific MIME type info, see
Expand Down
7 changes: 5 additions & 2 deletions lib/Minimal/Messagepart.php
Expand Up @@ -32,8 +32,11 @@ protected function _init()
}

if (isset($this->vars->atc)) {
$summary = $imp_contents->getSummary($this->vars->atc, IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP | IMP_Contents::SUMMARY_DOWNLOAD);

try {
$summary = $imp_contents->getSummary($this->vars->atc, IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP | IMP_Contents::SUMMARY_DOWNLOAD);
} catch (IMP_Exception $e) {
IMP_Minimal_Mailbox::url(array('mailbox' => $this->indices->mailbox))->add('a', 'm')->redirect();
}
$this->title = _("Download Attachment");

$this->view->descrip = $summary['description_raw'];
Expand Down

0 comments on commit 4f73dfd

Please sign in to comment.