mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
disable the use of tidy when using activesync
This commit is contained in:
parent
0b3cb4307c
commit
d7b3aab604
@ -699,7 +699,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi
|
|||||||
*/
|
*/
|
||||||
$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
|
$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
|
||||||
|
|
||||||
$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true);
|
$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
|
||||||
if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFF);
|
if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFF);
|
||||||
if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
|
if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
|
||||||
// may be html
|
// may be html
|
||||||
@ -711,7 +711,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi
|
|||||||
// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
|
// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
|
||||||
if ($orgMessageContentType!='text/html') $mailObject->IsHTML(false);
|
if ($orgMessageContentType!='text/html') $mailObject->IsHTML(false);
|
||||||
$bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display');
|
$bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display');
|
||||||
$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct);//$this->ui->getdisplayableBody($bodyStruct,false);
|
$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
|
||||||
|
|
||||||
if ($this->debugLevel>0) debugLog("MIME Body ContentType ".$mailObject->ContentType);
|
if ($this->debugLevel>0) debugLog("MIME Body ContentType ".$mailObject->ContentType);
|
||||||
$bodyBUFF = ($mailObject->ContentType=='text/html'?'<pre>':'').$bodyBUFF.($mailObject->ContentType=='text/html'?'</pre>':'');
|
$bodyBUFF = ($mailObject->ContentType=='text/html'?'<pre>':'').$bodyBUFF.($mailObject->ContentType=='text/html'?'</pre>':'');
|
||||||
@ -770,7 +770,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi
|
|||||||
*/
|
*/
|
||||||
//$body .= $this->mail->createHeaderInfoSection($headers,lang("original message"));
|
//$body .= $this->mail->createHeaderInfoSection($headers,lang("original message"));
|
||||||
$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
|
$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
|
||||||
$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true);
|
$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
|
||||||
if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$body);
|
if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$body);
|
||||||
if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
|
if ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
|
||||||
// may be html
|
// may be html
|
||||||
@ -782,7 +782,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi
|
|||||||
// as we glue together the send mail part, and the smartforward part, we stick to the ContentType of the to be sent-Mail
|
// as we glue together the send mail part, and the smartforward part, we stick to the ContentType of the to be sent-Mail
|
||||||
$mailObject->IsHTML($mailObject->ContentType=='text/html');
|
$mailObject->IsHTML($mailObject->ContentType=='text/html');
|
||||||
$bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display');
|
$bodyStruct = $this->mail->getMessageBody($uid,'never_display');//'never_display');
|
||||||
$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct);//$this->ui->getdisplayableBody($bodyStruct,false);
|
$bodyBUFF = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
|
||||||
|
|
||||||
if ($this->debugLevel>0) debugLog("MIME Body ContentType ".$mailObject->ContentType);
|
if ($this->debugLevel>0) debugLog("MIME Body ContentType ".$mailObject->ContentType);
|
||||||
$bodyBUFF = ($mailObject->ContentType=='text/html'?'<pre>':'').$bodyBUFF.($mailObject->ContentType=='text/html'?'</pre>':'');
|
$bodyBUFF = ($mailObject->ContentType=='text/html'?'<pre>':'').$bodyBUFF.($mailObject->ContentType=='text/html'?'</pre>':'');
|
||||||
@ -1047,7 +1047,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi
|
|||||||
if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers));
|
if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers));
|
||||||
if ($bodypreference === false) {
|
if ($bodypreference === false) {
|
||||||
$bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', '', true);
|
$bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', '', true);
|
||||||
$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct);
|
$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
|
||||||
$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body));
|
$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body));
|
||||||
if (stripos($body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $body); // in case there is only a html part
|
if (stripos($body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $body); // in case there is only a html part
|
||||||
// remove all other html
|
// remove all other html
|
||||||
@ -1080,7 +1080,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi
|
|||||||
$css ='';
|
$css ='';
|
||||||
$bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', '', true);
|
$bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', '', true);
|
||||||
if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct));
|
if ($this->debugLevel>2) debugLog(__METHOD__.__LINE__.' html_only Struct:'.array2string($bodyStruct));
|
||||||
$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true);//$this->ui->getdisplayableBody($bodyStruct,false);
|
$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
|
||||||
if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$body);
|
if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$body);
|
||||||
if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
|
if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
|
||||||
// may be html
|
// may be html
|
||||||
@ -1093,7 +1093,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi
|
|||||||
$output->airsyncbasenativebodytype=1;
|
$output->airsyncbasenativebodytype=1;
|
||||||
$bodyStruct = $this->mail->getMessageBody($id,'never_display', '', '', true); //'only_if_no_text');
|
$bodyStruct = $this->mail->getMessageBody($id,'never_display', '', '', true); //'only_if_no_text');
|
||||||
if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct));
|
if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' plain text Struct:'.array2string($bodyStruct));
|
||||||
$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct);//$this->ui->getdisplayableBody($bodyStruct,false);
|
$body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
|
||||||
if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' never display html(plain text only):'.$body);
|
if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' never display html(plain text only):'.$body);
|
||||||
}
|
}
|
||||||
// whatever format decode (using the correct encoding)
|
// whatever format decode (using the correct encoding)
|
||||||
@ -1109,7 +1109,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$plainBody = $this->mail->getdisplayableBody($this->mail,$bodyStructplain);//$this->ui->getdisplayableBody($bodyStruct,false);
|
$plainBody = $this->mail->getdisplayableBody($this->mail,$bodyStructplain,false,false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//if ($this->debugLevel>0) debugLog("MIME Body".$body);
|
//if ($this->debugLevel>0) debugLog("MIME Body".$body);
|
||||||
@ -1283,7 +1283,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi
|
|||||||
if ($this->debugLevel>0) debugLog("Plaintext Body:".$plainBody);
|
if ($this->debugLevel>0) debugLog("Plaintext Body:".$plainBody);
|
||||||
/* we use plainBody (set above) instead
|
/* we use plainBody (set above) instead
|
||||||
$bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display');
|
$bodyStruct = $this->mail->getMessageBody($id,'only_if_no_text'); //'never_display');
|
||||||
$plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct);//$this->ui->getdisplayableBody($bodyStruct,false);
|
$plain = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
|
||||||
$plain = html_entity_decode($plain,ENT_QUOTES,$this->mail->detect_encoding($plain));
|
$plain = html_entity_decode($plain,ENT_QUOTES,$this->mail->detect_encoding($plain));
|
||||||
$plain = strip_tags($plain);
|
$plain = strip_tags($plain);
|
||||||
//$plain = str_replace("\n","\r\n",str_replace("\r","",$plain));
|
//$plain = str_replace("\n","\r\n",str_replace("\r","",$plain));
|
||||||
|
@ -1543,66 +1543,34 @@ class felamimail_bo
|
|||||||
//if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) self::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); // Strip out stuff in ifs
|
//if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) self::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); // Strip out stuff in ifs
|
||||||
//if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) self::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs
|
//if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) self::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs
|
||||||
//error_log(__METHOD__.__LINE__.$_html);
|
//error_log(__METHOD__.__LINE__.$_html);
|
||||||
// force the use of kses, as it is still have the edge over purifier with some stuff
|
|
||||||
$usepurify = true;
|
if (get_magic_quotes_gpc() === 1) $_html = stripslashes($_html);
|
||||||
if ($usepurify)
|
// Strip out doctype in head, as htmlLawed cannot handle it TODO: Consider extracting it and adding it afterwards
|
||||||
{
|
if (stripos($_html,'!doctype')!==false) self::replaceTagsCompletley($_html,'!doctype');
|
||||||
// we need a customized config, as we may allow external images, $GLOBALS['egw_info']['user']['preferences']['felamimail']['allowExternalIMGs']
|
if (stripos($_html,'?xml:namespace')!==false) self::replaceTagsCompletley($_html,'\?xml:namespace','/>',false);
|
||||||
if (get_magic_quotes_gpc() === 1) $_html = stripslashes($_html);
|
if (stripos($_html,'?xml version')!==false) self::replaceTagsCompletley($_html,'\?xml version','\?>',false);
|
||||||
// Strip out doctype in head, as htmlLawed cannot handle it TODO: Consider extracting it and adding it afterwards
|
if (strpos($_html,'!CURSOR')!==false) self::replaceTagsCompletley($_html,'!CURSOR');
|
||||||
if (stripos($_html,'!doctype')!==false) self::replaceTagsCompletley($_html,'!doctype');
|
// htmLawed filter only the 'body'
|
||||||
if (stripos($_html,'?xml:namespace')!==false) self::replaceTagsCompletley($_html,'\?xml:namespace','/>',false);
|
//preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $_html, $matches);
|
||||||
if (stripos($_html,'?xml version')!==false) self::replaceTagsCompletley($_html,'\?xml version','\?>',false);
|
//if ($matches[2])
|
||||||
if (strpos($_html,'!CURSOR')!==false) self::replaceTagsCompletley($_html,'!CURSOR');
|
//{
|
||||||
// htmLawed filter only the 'body'
|
// $hasOther = true;
|
||||||
//preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $_html, $matches);
|
// $_html = $matches[2];
|
||||||
//if ($matches[2])
|
//}
|
||||||
//{
|
// purify got switched to htmLawed
|
||||||
// $hasOther = true;
|
// some testcode to test purifying / htmlawed
|
||||||
// $_html = $matches[2];
|
//$_html = "<BLOCKQUOTE>hi <div> there </div> kram <br> </blockquote>".$_html;
|
||||||
//}
|
$_html = html::purify($_html,self::$htmLawed_config,array(),true);
|
||||||
// purify got switched to htmLawed
|
//if ($hasOther) $_html = $matches[1]. $_html. $matches[3];
|
||||||
// some testcode to test purifying / htmlawed
|
// clean out comments , should not be needed as purify should do the job.
|
||||||
//$_html = "<BLOCKQUOTE>hi <div> there </div> kram <br> </blockquote>".$_html;
|
$search = array(
|
||||||
$_html = html::purify($_html,self::$htmLawed_config,array(),true);
|
'@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions
|
||||||
//if ($hasOther) $_html = $matches[1]. $_html. $matches[3];
|
'@<!--[\s\S]*?[ \t\n\r]*-->@', // Strip multi-line comments including CDATA
|
||||||
// clean out comments , should not be needed as purify should do the job.
|
);
|
||||||
$search = array(
|
$_html = preg_replace($search,"",$_html);
|
||||||
'@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions
|
// remove non printable chars
|
||||||
'@<!--[\s\S]*?[ \t\n\r]*-->@', // Strip multi-line comments including CDATA
|
$_html = preg_replace('/([\000-\012])/','',$_html);
|
||||||
);
|
//error_log($_html);
|
||||||
$_html = preg_replace($search,"",$_html);
|
|
||||||
// remove non printable chars
|
|
||||||
$_html = preg_replace('/([\000-\012])/','',$_html);
|
|
||||||
//error_log($_html);
|
|
||||||
}
|
|
||||||
// using purify above should have tidied the tags already sufficiently
|
|
||||||
if ($usepurify == false && $cleanTags==true)
|
|
||||||
{
|
|
||||||
if (extension_loaded('tidy'))
|
|
||||||
{
|
|
||||||
$tidy = new tidy();
|
|
||||||
$cleaned = $tidy->repairString($_html, 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
|
|
||||||
{
|
|
||||||
$_html = $cleaned;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//$to = ini_get('max_execution_time');
|
|
||||||
//@set_time_limit(10);
|
|
||||||
$htmLawed = new egw_htmLawed();
|
|
||||||
$_html = $htmLawed->egw_htmLawed($_html);
|
|
||||||
//error_log(__METHOD__.__LINE__.$_html);
|
|
||||||
//@set_time_limit($to);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -5215,12 +5183,12 @@ class felamimail_bo
|
|||||||
* @param array $bodyParts with the bodyparts
|
* @param array $bodyParts with the bodyparts
|
||||||
* @return string a preformatted string with the mails converted to text
|
* @return string a preformatted string with the mails converted to text
|
||||||
*/
|
*/
|
||||||
static function &getdisplayableBody(&$bofelamimail, $bodyParts, $preserveHTML = false)
|
static function &getdisplayableBody(&$bofelamimail, $bodyParts, $preserveHTML = false, $useTidy = true)
|
||||||
{
|
{
|
||||||
for($i=0; $i<count($bodyParts); $i++)
|
for($i=0; $i<count($bodyParts); $i++)
|
||||||
{
|
{
|
||||||
if (!isset($bodyParts[$i]['body'])) {
|
if (!isset($bodyParts[$i]['body'])) {
|
||||||
$bodyParts[$i]['body'] = self::getdisplayableBody($bofelamimail, $bodyParts[$i], $preserveHTML);
|
$bodyParts[$i]['body'] = self::getdisplayableBody($bofelamimail, $bodyParts[$i], $preserveHTML, $useTidy);
|
||||||
$message .= empty($bodyParts[$i]['body'])?'':$bodyParts[$i]['body'];
|
$message .= empty($bodyParts[$i]['body'])?'':$bodyParts[$i]['body'];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -5278,7 +5246,7 @@ 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'))
|
if ($useTidy && extension_loaded('tidy'))
|
||||||
{
|
{
|
||||||
$tidy = new tidy();
|
$tidy = new tidy();
|
||||||
$cleaned = $tidy->repairString($newBody, self::$tidy_config,'utf8');
|
$cleaned = $tidy->repairString($newBody, self::$tidy_config,'utf8');
|
||||||
|
Loading…
Reference in New Issue
Block a user