diff --git a/felamimail/inc/class.felamimail_activesync.inc.php b/felamimail/inc/class.felamimail_activesync.inc.php index d944311b61..b8381d82c9 100644 --- a/felamimail/inc/class.felamimail_activesync.inc.php +++ b/felamimail/inc/class.felamimail_activesync.inc.php @@ -699,7 +699,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi */ $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 ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/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 ($orgMessageContentType!='text/html') $mailObject->IsHTML(false); $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); $bodyBUFF = ($mailObject->ContentType=='text/html'?'
':'').$bodyBUFF.($mailObject->ContentType=='text/html'?'
':''); @@ -770,7 +770,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi */ //$body .= $this->mail->createHeaderInfoSection($headers,lang("original message")); $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 ($bodyBUFF != "" && (is_array($bodyStruct) && $bodyStruct[0]['mimeType']=='text/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 $mailObject->IsHTML($mailObject->ContentType=='text/html'); $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); $bodyBUFF = ($mailObject->ContentType=='text/html'?'
':'').$bodyBUFF.($mailObject->ContentType=='text/html'?'
':''); @@ -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 ($bodypreference === false) { $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)); if (stripos($body,'/is", "", $body); // in case there is only a html part // remove all other html @@ -1080,7 +1080,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi $css =''; $bodyStruct = $this->mail->getMessageBody($id, 'html_only', '', '', true); 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 @@ -1093,7 +1093,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi $output->airsyncbasenativebodytype=1; $bodyStruct = $this->mail->getMessageBody($id,'never_display', '', '', true); //'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) @@ -1109,7 +1109,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi } 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); @@ -1283,7 +1283,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi 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,false,false); $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)); diff --git a/felamimail/inc/class.felamimail_bo.inc.php b/felamimail/inc/class.felamimail_bo.inc.php index d0355dbce8..a847ceda68 100644 --- a/felamimail/inc/class.felamimail_bo.inc.php +++ b/felamimail/inc/class.felamimail_bo.inc.php @@ -1543,66 +1543,34 @@ class felamimail_bo //if (stripos($_html,'![if')!==false && stripos($_html,'')!==false) self::replaceTagsCompletley($_html,'!\[if','',false); // Strip out stuff in ifs //if (stripos($_html,'!--[if')!==false && stripos($_html,'')!==false) self::replaceTagsCompletley($_html,'!--\[if','',false); // Strip out stuff in ifs //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 ($usepurify) - { - // we need a customized config, as we may allow external images, $GLOBALS['egw_info']['user']['preferences']['felamimail']['allowExternalIMGs'] - if (get_magic_quotes_gpc() === 1) $_html = stripslashes($_html); - // 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'); - if (stripos($_html,'?xml:namespace')!==false) self::replaceTagsCompletley($_html,'\?xml:namespace','/>',false); - if (stripos($_html,'?xml version')!==false) self::replaceTagsCompletley($_html,'\?xml version','\?>',false); - if (strpos($_html,'!CURSOR')!==false) self::replaceTagsCompletley($_html,'!CURSOR'); - // htmLawed filter only the 'body' - //preg_match('`(]*>)(.+?)(.*?)`ims', $_html, $matches); - //if ($matches[2]) - //{ - // $hasOther = true; - // $_html = $matches[2]; - //} - // purify got switched to htmLawed - // some testcode to test purifying / htmlawed - //$_html = "
hi
there
kram
".$_html; - $_html = html::purify($_html,self::$htmLawed_config,array(),true); - //if ($hasOther) $_html = $matches[1]. $_html. $matches[3]; - // clean out comments , should not be needed as purify should do the job. - $search = array( - '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions - '@@', // Strip multi-line comments including CDATA - ); - $_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); - } - } + + if (get_magic_quotes_gpc() === 1) $_html = stripslashes($_html); + // 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'); + if (stripos($_html,'?xml:namespace')!==false) self::replaceTagsCompletley($_html,'\?xml:namespace','/>',false); + if (stripos($_html,'?xml version')!==false) self::replaceTagsCompletley($_html,'\?xml version','\?>',false); + if (strpos($_html,'!CURSOR')!==false) self::replaceTagsCompletley($_html,'!CURSOR'); + // htmLawed filter only the 'body' + //preg_match('`(]*>)(.+?)(.*?)`ims', $_html, $matches); + //if ($matches[2]) + //{ + // $hasOther = true; + // $_html = $matches[2]; + //} + // purify got switched to htmLawed + // some testcode to test purifying / htmlawed + //$_html = "
hi
there
kram
".$_html; + $_html = html::purify($_html,self::$htmLawed_config,array(),true); + //if ($hasOther) $_html = $matches[1]. $_html. $matches[3]; + // clean out comments , should not be needed as purify should do the job. + $search = array( + '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions + '@@', // Strip multi-line comments including CDATA + ); + $_html = preg_replace($search,"",$_html); + // remove non printable chars + $_html = preg_replace('/([\000-\012])/','',$_html); + //error_log($_html); } /** @@ -5215,12 +5183,12 @@ class felamimail_bo * @param array $bodyParts with the bodyparts * @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 peplace it with a single space $newBody = str_replace("\n"," ",$newBody); // convert HTML to text, as we dont want HTML in infologs - if (extension_loaded('tidy')) + if ($useTidy && extension_loaded('tidy')) { $tidy = new tidy(); $cleaned = $tidy->repairString($newBody, self::$tidy_config,'utf8');