diff --git a/felamimail/inc/class.felamimail_bo.inc.php b/felamimail/inc/class.felamimail_bo.inc.php index 05281436f4..179b83547f 100644 --- a/felamimail/inc/class.felamimail_bo.inc.php +++ b/felamimail/inc/class.felamimail_bo.inc.php @@ -26,10 +26,18 @@ class felamimail_bo ); static $debug = false; //true; // sometimes debuging is quite handy, to see things. check with the error log to see results + // define some constants // message types var $type = array("text", "multipart", "message", "application", "audio", "image", "video", "other"); + /** + * static used to configure tidy - if tidy is loadable, this config is used with tidy to straighten out html, instead of using purifiers tidy mode + * + * @array + */ + static $tidy_config = array('clean'=>true,'output-html'=>true,'join-classes'=>true,'join-styles'=>true,'show-body-only'=>"auto",'word-2000'=>true,'wrap'=>0); + /** * errorMessage * @@ -40,12 +48,14 @@ class felamimail_bo // message encodings var $encoding = array("7bit", "8bit", "binary", "base64", "quoted-printable", "other"); static $displayCharset; + /** * Instance of bopreference * * @var bopreferences */ var $bopreferences; + /** * Active preferences * @@ -1452,7 +1462,7 @@ class felamimail_bo if (extension_loaded('tidy')) { $tidy = new tidy(); - $cleaned = $tidy->repairString($_html, array('clean'=>true,'output-html'=>true,'join-classes'=>true,'join-styles'=>true,'show-body-only'=>"auto",'word-2000'=>true,'wrap'=>0),'utf8'); + $cleaned = $tidy->repairString($_html, self::$tidy_config,'utf8'); // Found errors. Strip it all so there's some output if($tidy->getStatus() == 2) { @@ -4456,7 +4466,24 @@ class felamimail_bo // as translation::convert reduces \r\n to \n and purifier eats \n -> peplace it with a single space $newBody = str_replace("\n"," ",$newBody); // convert HTML to text, as we dont want HTML in infologs - $newBody = html::purify($newBody); + if (extension_loaded('tidy')) + { + $tidy = new tidy(); + $cleaned = $tidy->repairString($newBody, self::$tidy_config,'utf8'); + // Found errors. Strip it all so there's some output + if($tidy->getStatus() == 2) + { + error_log(__METHOD__.__LINE__.' ->'.$tidy->errorBuffer); + } + else + { + $newBody = $cleaned; + } + } + else + { + $newBody = html::purify($newBody); + } //error_log(__METHOD__.__LINE__.' after purify:'.$newBody); if ($preserveHTML==false) $newBody = $bofelamimail->convertHTMLToText($newBody,true); $bofelamimail->getCleanHTML($newBody,false,$preserveHTML); // new Body passed by reference