mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-02 19:39:26 +01:00
* email/esync: using tidy (if loadable) instead of purifier to straighten out html when retieving the displayableBody. This is due to performance considerations, and problems with purifier on large html chunks, with lots of tables. (This affects converting emails to infolog and tracker as well)
This commit is contained in:
parent
818735e5a2
commit
fe98471d18
@ -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
|
static $debug = false; //true; // sometimes debuging is quite handy, to see things. check with the error log to see results
|
||||||
|
|
||||||
// define some constants
|
// define some constants
|
||||||
// message types
|
// message types
|
||||||
var $type = array("text", "multipart", "message", "application", "audio", "image", "video", "other");
|
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
|
* errorMessage
|
||||||
*
|
*
|
||||||
@ -40,12 +48,14 @@ class felamimail_bo
|
|||||||
// message encodings
|
// message encodings
|
||||||
var $encoding = array("7bit", "8bit", "binary", "base64", "quoted-printable", "other");
|
var $encoding = array("7bit", "8bit", "binary", "base64", "quoted-printable", "other");
|
||||||
static $displayCharset;
|
static $displayCharset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instance of bopreference
|
* Instance of bopreference
|
||||||
*
|
*
|
||||||
* @var bopreferences
|
* @var bopreferences
|
||||||
*/
|
*/
|
||||||
var $bopreferences;
|
var $bopreferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Active preferences
|
* Active preferences
|
||||||
*
|
*
|
||||||
@ -1452,7 +1462,7 @@ class felamimail_bo
|
|||||||
if (extension_loaded('tidy'))
|
if (extension_loaded('tidy'))
|
||||||
{
|
{
|
||||||
$tidy = new 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
|
// Found errors. Strip it all so there's some output
|
||||||
if($tidy->getStatus() == 2)
|
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
|
// as translation::convert reduces \r\n to \n and purifier eats \n -> peplace it with a single space
|
||||||
$newBody = str_replace("\n"," ",$newBody);
|
$newBody = str_replace("\n"," ",$newBody);
|
||||||
// convert HTML to text, as we dont want HTML in infologs
|
// convert HTML to text, as we dont want HTML in infologs
|
||||||
|
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);
|
$newBody = html::purify($newBody);
|
||||||
|
}
|
||||||
//error_log(__METHOD__.__LINE__.' after purify:'.$newBody);
|
//error_log(__METHOD__.__LINE__.' after purify:'.$newBody);
|
||||||
if ($preserveHTML==false) $newBody = $bofelamimail->convertHTMLToText($newBody,true);
|
if ($preserveHTML==false) $newBody = $bofelamimail->convertHTMLToText($newBody,true);
|
||||||
$bofelamimail->getCleanHTML($newBody,false,$preserveHTML); // new Body passed by reference
|
$bofelamimail->getCleanHTML($newBody,false,$preserveHTML); // new Body passed by reference
|
||||||
|
Loading…
Reference in New Issue
Block a user