Skip to content
Snippets Groups Projects
Commit 469889d2 authored by Jared Hancock's avatar Jared Hancock
Browse files

thread: Avoid crash with multiple Message-ID headers

parent f1e31ba6
No related branches found
No related tags found
No related merge requests found
...@@ -346,10 +346,15 @@ class MailFetcher { ...@@ -346,10 +346,15 @@ class MailFetcher {
// Ensure we have a message-id. If unable to read it out of the // Ensure we have a message-id. If unable to read it out of the
// email, use the hash of the entire email headers // email, use the hash of the entire email headers
if (!$header['mid'] && $header['header']) if (!$header['mid'] && $header['header']) {
if (!($header['mid'] = Mail_Parse::findHeaderEntry($header['header'], $header['mid'] = Mail_Parse::findHeaderEntry($header['header'],
'message-id'))) 'message-id');
if (is_array($header['mid']))
$header['mid'] = array_pop(array_filter($header['mid']));
if (!$header['mid'])
$header['mid'] = '<' . md5($header['header']) . '@local>'; $header['mid'] = '<' . md5($header['header']) . '@local>';
}
return $header; return $header;
} }
......
...@@ -242,8 +242,11 @@ class Mail_Parse { ...@@ -242,8 +242,11 @@ class Mail_Parse {
} }
function getMessageId(){ function getMessageId(){
if (!($mid = $this->struct->headers['message-id'])) if (($mid = $this->struct->headers['message-id']) && is_array($mid))
$mid = array_pop(array_filter($mid));
if (!$mid)
$mid = sprintf('<%s@local>', md5($this->getHeader())); $mid = sprintf('<%s@local>', md5($this->getHeader()));
return $mid; return $mid;
} }
......
...@@ -803,7 +803,8 @@ Class ThreadEntry { ...@@ -803,7 +803,8 @@ Class ThreadEntry {
function saveEmailInfo($vars) { function saveEmailInfo($vars) {
if(!$vars || !$vars['mid']) // Don't save empty message ID
if (!$vars || !$vars['mid'])
return 0; return 0;
$this->ht['email_mid'] = $vars['mid']; $this->ht['email_mid'] = $vars['mid'];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment