function removeEvilTags($source)
{
$allowedTags = '<h1><b><i><a><ul><li><pre><hr><blockquote><img><br><font><p><small><big><sup><sub><code><em>';
+ $source = preg_replace('|</div>|i', '<br />', $source);
$source = strip_tags($source, $allowedTags);
return preg_replace('/<(.*?)>/ie', "'<'.removeEvilAttributes('\\1').'>'", $source);
}
*/
function htmlToPlainText($res)
{
- $res = trim(html_entity_decode(strip_tags($res, '<br><p>')));
- $res = preg_replace("@</?(br|p)[^>]*>@i", "\n", $res);
+ $res = trim(html_entity_decode(strip_tags($res, '<div><br><p>')));
+ $res = preg_replace("@</?(br|p|div)[^>]*>@i", "\n", $res);
if (!is_utf8($res)) {
$res = utf8_encode($res);
}
function formatbody($_text, $format='plain')
{
if ($format == 'html') {
- $res = '<br/>'.removeEvilTags($_text).'<br/>';
+ $res = '<br/>'.html_entity_decode(to_entities(removeEvilTags($_text))).'<br/>';
} else if ($format == 'richtext') {
- $res = '<br/>'.richtextToHtml($_text).'<br/>';
+ $res = '<br/>'.html_entity_decode(to_entities(richtextToHtml($_text))).'<br/>';
$format = 'html';
} else {
$res = "\n\n" . to_entities(wrap($_text, ""))."\n\n";
break;
}
}
- return Array('headers' => $local_headers, 'body' => join("\n", $lines));
+ $local_body = join("\n", $lines);
+ if (preg_match("/quoted-printable/", $local_headers['content-transfer-encoding'])) {
+ $local_body = quoted_printable_decode($local_body);
+ }
+ return Array('headers' => $local_headers, 'body' => $local_body);
}
/** add an attachment
$this->body = iconv($matches[1], 'utf-8', $this->body);
} else {
$this->body = utf8_encode($this->body);
- }
+ }
return true;
}