disable the use of tidy when using zpush/activesync

This commit is contained in:
Klaus Leithoff 2015-10-23 10:02:18 +00:00
parent 6886b0a3b1
commit 294b3c2ea8
4 changed files with 28 additions and 26 deletions

View File

@ -537,7 +537,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
$this->mail->reopen($folder);
$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true);
$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
// may be html
@ -549,7 +549,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text:');
// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
$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 ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) {
if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain;
@ -609,7 +609,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
$this->mail->reopen($folder);
$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true);
$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
if ($this->debugLevel>3) debugLog(__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
// may be html
@ -621,7 +621,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain, fetch text:');
// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
$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 ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) {
if ($this->debugLevel>0) debugLog("MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain;
@ -819,7 +819,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
if ($this->debugLevel>0) debugLog(__METHOD__.__LINE__. ' for message with ID:'.$id.' with headers:'.array2string($headers));
if ($bodypreference === false) {
$bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName);
$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));
if (stripos($body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $body); // in case there is only a html part
// remove all other html
@ -852,7 +852,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
$css ='';
$bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName);
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 ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
// may be html
@ -865,7 +865,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
$output->airsyncbasenativebodytype=1;
$bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text');
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);
}
// whatever format decode (using the correct encoding)
@ -881,7 +881,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
}
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);
@ -1033,7 +1033,7 @@ class mail_activesync implements activesync_plugin_write, activesync_plugin_send
if ($this->debugLevel>0) debugLog("Plaintext Body:".$plainBody);
/* we use plainBody (set above) instead
$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);
$plain = html_entity_decode($plain,ENT_QUOTES,$this->mail->detect_encoding($plain));
$plain = strip_tags($plain);
//$plain = str_replace("\n","\r\n",str_replace("\r","",$plain));

View File

@ -552,7 +552,7 @@ class mail_compose
$content['mail_htmltext'] = implode('',$contentArr);
}
}
$content['mail_htmltext'] = $this->_getCleanHTML($content['mail_htmltext'], false, false);
$content['mail_htmltext'] = $this->_getCleanHTML($content['mail_htmltext']);
$content['mail_htmltext'] = translation::convertHTMLToText($content['mail_htmltext'],$charset=false,false,true);
$content['body'] = $content['mail_htmltext'];
@ -2127,12 +2127,12 @@ class mail_compose
}
static function _getCleanHTML($_body, $usepurify = false, $cleanTags=true)
static function _getCleanHTML($_body)
{
static $nonDisplayAbleCharacters = array('[\016]','[\017]',
'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
mail_bo::getCleanHTML($_body, $usepurify, $cleanTags);
mail_bo::getCleanHTML($_body);
return preg_replace($nonDisplayAbleCharacters, '', $_body);
}
@ -2299,7 +2299,7 @@ class mail_compose
}
else
{
$body = $this->convertHTMLToText($_formData['body'],false);
$this->convertHTMLToText($_formData['body'],false);
if ($attachment_links) $body .= $attachment_links;

View File

@ -2741,11 +2741,13 @@ class mail_ui
{
$singleBodyPart['body'] = preg_replace($sar,$rar,$singleBodyPart['body']);
}
//error_log(__METHOD__.__LINE__.'reports:'.$singleBodyPart['charSet']);
$singleBodyPart['body'] = translation::convert_jsonsafe($singleBodyPart['body'],$singleBodyPart['charSet']);
//error_log(__METHOD__.__LINE__.array2string($singleBodyPart));
if($singleBodyPart['mimeType'] == 'text/plain')
{
$newBody = @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(mail_bo::$displayCharset));
//error_log(__METHOD__.__LINE__.'..'.$newBody);
// if empty and charset is utf8 try sanitizing the string in question
if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(mail_bo::$displayCharset));
// if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso-
@ -2757,6 +2759,7 @@ class mail_ui
// create links for websites
if ($modifyURI) $newBody = html::activate_links($newBody);
//error_log(__METHOD__.__LINE__.'..'.$newBody);
// redirect links for websites if you use no cookies
#if (!($GLOBALS['egw_info']['server']['usecookies']))
# $newBody = preg_replace("/href=(\"|\')((http(s?):\/\/)|(www\.))([\w,\-,\/,\?,\=,\.,&amp;,!\n,\%,@,\(,\),\*,#,:,~,\+]+)(\"|\')/ie",
@ -2774,7 +2777,7 @@ class mail_ui
// to display a mailpart of mimetype plain/text, may be better taged as preformatted
#$newBody = nl2br($newBody);
// since we do not display the message as HTML anymore we may want to insert good linebreaking (for visibility).
//error_log($newBody);
//error_log(__METHOD__.__LINE__.'..'.$newBody);
// dont break lines that start with > (&gt; as the text was processed with htmlentities before)
$newBody = "<pre>".mail_bo::wordwrap($newBody,90,"\n",'&gt;')."</pre>";
}
@ -2785,9 +2788,8 @@ class mail_ui
#error_log(print_r($newBody,true));
// do the cleanup, set for the use of purifier
$usepurifier = true;
$newBodyBuff = $newBody;
mail_bo::getCleanHTML($newBody,$usepurifier);
mail_bo::getCleanHTML($newBody);
// in a way, this tests if we are having real utf-8 (the displayCharset) by now; we should if charsets reported (or detected) are correct
if (strtoupper(mail_bo::$displayCharset) == 'UTF-8')
{
@ -2798,7 +2800,7 @@ class mail_ui
$newBody = $newBodyBuff;
$tv = mail_bo::$htmLawed_config['tidy'];
mail_bo::$htmLawed_config['tidy'] = 0;
mail_bo::getCleanHTML($newBody,$usepurifier);
mail_bo::getCleanHTML($newBody);
mail_bo::$htmLawed_config['tidy'] = $tv;
}
}

View File

@ -554,7 +554,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
$this->mail->reopen($folder);
$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true);
$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
// may be html
@ -566,7 +566,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
$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 ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) {
if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain;
@ -626,7 +626,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
$this->mail->reopen($folder);
$bodyStruct = $this->mail->getMessageBody($uid, 'html_only');
$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true);
$bodyBUFFHtml = $this->mail->getdisplayableBody($this->mail,$bodyStruct,true,false);
if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$bodyBUFFHtml);
if ($bodyBUFFHtml != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
// may be html
@ -638,7 +638,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain, fetch text:');
// if the new part of the message is html, we must preserve it, and handle that the original mail is text/plain
$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 ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/plain')) {
if ($this->debugLevel>0) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__."(".__LINE__.") MIME Body".' Type:plain (fetched with never_display):'.$bodyBUFF);
$Body = $Body."\r\n".$bodyBUFF.$sigTextPlain;
@ -849,7 +849,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
if ($bodypreference === false) {
$bodyStruct = $this->mail->getMessageBody($id, 'only_if_no_text', '', null, true,$_folderName);
$raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct);
$raw_body = $this->mail->getdisplayableBody($this->mail,$bodyStruct,false,false);
//$body = html_entity_decode($body,ENT_QUOTES,$this->mail->detect_encoding($body));
if (stripos($raw_body,'<style')!==false) $body = preg_replace("/<style.*?<\/style>/is", "", $raw_body); // in case there is only a html part
// remove all other html
@ -889,7 +889,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
$css ='';
$bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', null, true,$_folderName);
if ($this->debugLevel>2) ZLog::Write(LOGLEVEL_DEBUG,__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) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' html_only:'.$body);
if ($body != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/html')) {
// may be html
@ -902,7 +902,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
$output->nativebodytype=1;
$bodyStruct = $this->mail->getMessageBody($id,'never_display', '', null, true,$_folderName); //'only_if_no_text');
if ($this->debugLevel>3) ZLog::Write(LOGLEVEL_DEBUG,__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) ZLog::Write(LOGLEVEL_DEBUG,__METHOD__.__LINE__.' never display html(plain text only):'.$body);
}
// whatever format decode (using the correct encoding)
@ -919,7 +919,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
}
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);
@ -977,7 +977,7 @@ class mail_zpush implements activesync_plugin_write, activesync_plugin_sendmail,
if ($this->debugLevel>0) debugLog("Plaintext Body:".$plainBody);
/* we use plainBody (set above) instead
$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);
$plain = html_entity_decode($plain,ENT_QUOTES,$this->mail->detect_encoding($plain));
$plain = strip_tags($plain);
//$plain = str_replace("\n","\r\n",str_replace("\r","",$plain));