diff --git a/include/class.mailfetch.php b/include/class.mailfetch.php index f1ce7fdc75bf590efa9c46eaff30045e78e6795a..9c4afe9b4005e4a3844c6b536473ff9718a5eb69 100644 --- a/include/class.mailfetch.php +++ b/include/class.mailfetch.php @@ -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); } diff --git a/include/class.mailparse.php b/include/class.mailparse.php index eacd62d2a24b44db7a6f66c38411ca9bf5a885f5..eca76a0b753ebba8167e71b78f5f6411d65e0e7c 100644 --- a/include/class.mailparse.php +++ b/include/class.mailparse.php @@ -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']; }