{
$res = trim(html_entity_decode(strip_tags($res, '<br>')));
$res = preg_replace("@<br[^>]>@i", "\n", $res);
+ if (!is_utf8($res)) {
+ $res = utf8_encode($res);
+ }
return $res;
}
function formatbody($_text, $format='plain')
{
if ($format == 'html') {
- $res = '<br/>'.removeEvilTags(html_entity_decode(to_entities($_text))).'<br/>';
+ $res = '<br/>'.removeEvilTags($_text).'<br/>';
} else if ($format == 'richtext') {
- $res = '<br/>'.richtextToHtml(html_entity_decode(to_entities($_text))).'<br/>';
+ $res = '<br/>'.richtextToHtml($_text).'<br/>';
$format = 'html';
} else {
$res = "\n\n" . to_entities(wrap($_text, ""))."\n\n";
preg_match("@text/([^;]+);@", $this->headers['content-type'], $format);
$format = $format[1];
- $res .= '<tr><td colspan="2">';
+ $res .= '<tr><td colspan="2"';
if ($format == 'html') {
- $res .= formatbody($this->body, $format);
+ if (preg_match('@<body[^>]*bgcolor="?([#0-9a-f]+)"?[^>]*>@i', $this->body, $bgcolor)) {
+ $res .= ' bgcolor="'.$bgcolor[1].'"';
+ }
+ $res .= '>'.formatbody($this->body, $format);
} else {
- $res .= '<pre>'.formatbody($this->body).'</pre>';
+ $res .= '><pre>'.formatbody($this->body).'</pre>';
}
$res .= '</td></tr>';