diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index 6fcf638514..9a0b520f17 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -1665,6 +1665,7 @@ class infolog_ui if ($bodyParts[$i]['mimeType'] == 'text/html') { // convert HTML to text, as we dont want HTML in infologs + $newBody = html::purify($newBody); $newBody = $bofelamimail->convertHTMLToText($newBody,true); $bofelamimail->getCleanHTML($newBody); // new Body passed by reference $message .= $newBody; diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index 6148051de9..1fb6200132 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -1443,5 +1443,30 @@ class html } } } + + /** + * split html by PRE tag, return array with all content pre-sections isolated in array elements + * @author Leithoff, Klaus + * @param string html + * @return mixed array of parts or unaffected html + */ + static function splithtmlByPRE($html) + { + if (($pos = stripos($html,'
')) === false) + { + return $html; + } + $html2ret[] = substr($html,0,$pos); + while ($pos!==false) + { + $endofpre = stripos($html,'',$pos); + $length = $endofpre-$pos+6; + $html2ret[] = substr($html,$pos,$length); + $pos = stripos($html,'
', $endofpre+6); + $html2ret[] = ($pos ? substr($html,$endofpre+6,$pos-($endofpre+6)): substr($html,$endofpre+6)); + //$pos=false; + } + return $html2ret; + } } html::_init_static(); diff --git a/phpgwapi/inc/class.translation.inc.php b/phpgwapi/inc/class.translation.inc.php index de0a762e7d..6b7cc45db1 100644 --- a/phpgwapi/inc/class.translation.inc.php +++ b/phpgwapi/inc/class.translation.inc.php @@ -1139,6 +1139,7 @@ class translation '@&(pound|#163);@i', // Pound '@&(copy|#169);@i', // Copyright '@&(reg|#174);@i', // Registered + '@'@i', // singleQuote ); $Replace = array ('', '"', @@ -1151,11 +1152,26 @@ class translation chr(163), chr(169), chr(174), + "'", ); $_html = preg_replace($Rules, $Replace, $_html); - // removing carriage return linefeeds - if ($stripcrl === true ) $_html = preg_replace('@(\r\n)@i',' ',$_html); + // removing carriage return linefeeds, preserve those enclosed intags + if ($stripcrl === true ) + { + if (stripos($_html,'')!==false) + { + $contentArr = html::splithtmlByPRE($_html); + foreach ($contentArr as $k =>&$elem) + { + if (stripos($elem,'')===false) + { + $elem = preg_replace('@(\r\n)@i',' ',$elem); + } + } + $_html = implode('',$contentArr); + } + } $tags = array ( 0 => '~]*>\r*\n*~si', 1 => '~ ]*>\r*\n*~si', @@ -1168,6 +1184,9 @@ class translation 8 => '~ ]*>\r*\n*~si', 9 => '~
]*>\r*\n*~si', 10 => '//', + 11 => '//', + 12 => '~~si', + 13 => '~]*>~si', ); $Replace = array ( 0 => "\r\n", @@ -1181,6 +1200,9 @@ class translation 8 => "\r\n", 9 => "\r\n__________________________________________________\r\n", 10 => '#blockquote#type#cite#', + 11 => '#blockquote#type#cite#', + 12 => '#blockquote#end#cite#', + 13 => '#blockquote#type#cite#', ); $_html = preg_replace($tags,$Replace,$_html); $_html = preg_replace('~\s*]*>~si',' - ',$_html); @@ -1200,7 +1222,7 @@ class translation #$_html = preg_replace('~^\s+~m','',$_html); #$_html = preg_replace('~\s+$~m','',$_html); // restoring the preserved blockquote - $_html = preg_replace('~#blockquote#type#cite#~s',' ',$_html); + //$_html = str_replace('#blockquote#type#cite#','',$_html); $_html = html_entity_decode($_html, ENT_COMPAT, $displayCharset); @@ -1214,14 +1236,15 @@ class translation $indent = 0; $indentString = ''; - $quoteParts = preg_split('//', $_html, -1, PREG_SPLIT_OFFSET_CAPTURE); - + //$quoteParts = preg_split('//', $_html, -1, PREG_SPLIT_OFFSET_CAPTURE); + $quoteParts = preg_split('/#blockquote#type#cite#/', $_html, -1, PREG_SPLIT_OFFSET_CAPTURE); foreach($quoteParts as $quotePart) { if($quotePart[1] > 0) { $indent++; $indentString .= '>'; } - $quoteParts2 = preg_split('/<\/blockquote>/', $quotePart[0], -1, PREG_SPLIT_OFFSET_CAPTURE); + //$quoteParts2 = preg_split('/<\/blockquote>/', $quotePart[0], -1, PREG_SPLIT_OFFSET_CAPTURE); + $quoteParts2 = preg_split('/#blockquote#end#cite#/', $quotePart[0], -1, PREG_SPLIT_OFFSET_CAPTURE); foreach($quoteParts2 as $quotePart2) { if($quotePart2[1] > 0) {