Skip to content
Snippets Groups Projects
Commit 897ef322 authored by Peter Rotich's avatar Peter Rotich
Browse files

Decide the thread body type at email parsing time.

This would in theory allow us to decide at the email level the content type
to accept.
parent 433d7377
No related branches found
No related tags found
No related merge requests found
......@@ -472,10 +472,8 @@ class MailFetcher {
foreach ($struct->parameters as $p) {
if (strtolower($p->attribute) == 'report-type'
&& $p->value == 'delivery-status') {
return sprintf('<pre>%s</pre>',
Format::htmlchars(
$this->getPart($mid, 'text/plain', $this->charset, $struct, false, 1)
));
return new TextThreadBody( $this->getPart(
$mid, 'text/plain', $this->charset, $struct, false, 1));
}
}
}
......@@ -501,27 +499,23 @@ class MailFetcher {
global $cfg;
if ($cfg->isHtmlThreadEnabled()) {
if ($body=$this->getPart($mid, 'text/html', $this->charset)) {
//Cleanup the html.
$body = (trim($body, " <>br/\t\n\r"))
? Format::safe_html($body)
: '--';
}
elseif ($body=$this->getPart($mid, 'text/plain', $this->charset)) {
$body = trim($body)
? sprintf('<pre>%s</pre>',
Format::htmlchars($body))
: '--';
}
}
else {
if (!($body=$this->getPart($mid, 'text/plain', $this->charset))) {
if ($body=$this->getPart($mid, 'text/html', $this->charset)) {
$body = Format::html2text(Format::safe_html($body), 100, false);
}
}
$body = trim($body) ? $body : '--';
if ($html=$this->getPart($mid, 'text/html', $this->charset))
$body = new HtmlThreadBody($html);
elseif ($text=$this->getPart($mid, 'text/plain', $this->charset))
$body = new TextThreadBody($text);
}
elseif ($text=$this->getPart($mid, 'text/plain', $this->charset))
$body = new TextThreadBody($text);
elseif ($html=$this->getPart($mid, 'text/html', $this->charset))
$body = new TextThreadBody(
Format::html2text(Format::safe_html($html),
100, false));
else
$body = new TextThreadBody('');
if ($cfg->stripQuotedReply())
$body->stripQuotedReply($cfg->getReplySeparator());
return $body;
}
......@@ -572,7 +566,7 @@ class MailFetcher {
$vars['thread-type'] = 'N';
}
else {
$vars['message'] = Format::stripEmptyLines($this->getBody($mid));
$vars['message'] = $this->getBody($mid);
}
......
......@@ -229,27 +229,23 @@ class Mail_Parse {
global $cfg;
if ($cfg->isHtmlThreadEnabled()) {
if ($body=$this->getPart($this->struct,'text/html')) {
// Cleanup the html -- Balance html tags & neutralize unsafe tags.
$body = (trim($body, " <>br/\t\n\r"))
? Format::safe_html($body)
: '--';
}
elseif ($body=$this->getPart($this->struct,'text/plain')) {
$body = trim($body)
? sprintf('<pre>%s</pre>',
Format::htmlchars($body))
: '--';
}
}
else {
if (!($body=$this->getPart($this->struct,'text/plain'))) {
if ($body=$this->getPart($this->struct,'text/html')) {
$body = Format::html2text(Format::safe_html($body), 100, false);
}
}
$body = trim($body) ? $body : '--';
if ($html=$this->getPart($this->struct,'text/html'))
$body = new HtmlThreadBody($html);
elseif ($text=$this->getPart($this->struct,'text/plain'))
$body = new TextThreadBody($text);
}
elseif ($text=$this->getPart($this->struct,'text/plain'))
$body = new TextThreadBody($text);
elseif ($html=$this->getPart($this->struct,'text/html'))
$body = new TextThreadBody(
Format::html2text(Format::safe_html($html),
100, false));
else
$body = new TextThreadBody('');
if ($cfg->stripQuotedReply())
$body->stripQuotedReply($cfg->getReplySeparator());
return $body;
}
......@@ -481,7 +477,7 @@ class EmailDataParser {
}
else {
// Typical email
$data['message'] = Format::stripEmptyLines($parser->getBody());
$data['message'] = $parser->getBody();
$data['in-reply-to'] = $parser->struct->headers['in-reply-to'];
$data['references'] = $parser->struct->headers['references'];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment