From 04760c6510462c055077dbcbefd6492d6816c476 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Mon, 14 Apr 2014 15:09:07 +0000 Subject: [PATCH] rework of translation::replaceTagsCompletley as the prior method removed too much in rare cases --- phpgwapi/inc/class.html.inc.php | 7 ++++++- phpgwapi/inc/class.translation.inc.php | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index 069d196b5d..6faf819e3a 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -1590,6 +1590,9 @@ egw_LAB.wait(function() { { //error_log(__METHOD__.__LINE__.array2string($newStyle[0])); $style2buffer = implode('',$newStyle[0]); + // only replace what we have found, we use it here, as we use the same routine in translation::replaceTagsCompletley + // no need to do the extra routine + $html = str_ireplace($newStyle[0],'',$html); } if ($style2buffer) { @@ -1621,8 +1624,10 @@ egw_LAB.wait(function() { // as the comments as in stylesheet are outdated, and ck-editor does not understand it, we remove it $css_no_comment = str_replace(array(':',''),array(': ','',''),$css); //error_log(__METHOD__.__LINE__.$css); + // we already removed what we have found, above, as we used pretty much the same routine as in translation::replaceTagsCompletley + // no need to do the extra routine // TODO: we may have to strip urls and maybe comments and ifs - if (stripos($html,'style')!==false) translation::replaceTagsCompletley($html,'style'); // clean out empty or pagewide style definitions / left over tags + //if (stripos($html,'style')!==false) translation::replaceTagsCompletley($html,'style'); // clean out empty or pagewide style definitions / left over tags return $css_no_comment; } } diff --git a/phpgwapi/inc/class.translation.inc.php b/phpgwapi/inc/class.translation.inc.php index 0d9339fa7f..d8ed0241d1 100644 --- a/phpgwapi/inc/class.translation.inc.php +++ b/phpgwapi/inc/class.translation.inc.php @@ -1086,15 +1086,31 @@ class translation } else { + $found=null; if ($addbracesforendtag === true ) { - $_body = preg_replace('~<'.$tag.'[^>]*?>(.*?)~simU','',$_body); + if (stripos($_body,'<'.$tag)!==false) $ct = preg_match_all('#<'.$tag.'(?:\s.*)?>(.+)#isU', $_body, $found); + if ($ct>0) + { + //error_log(__METHOD__.__LINE__.array2string($found[0])); + // only replace what we have found + $_body = str_ireplace($found[0],'',$_body); + } // remove left over tags, unfinished ones, and so on $_body = preg_replace('~<'.$tag.'[^>]*?>~si','',$_body); } if ($addbracesforendtag === false ) { + if (stripos($_body,'<'.$tag)!==false) $ct = preg_match_all('#<'.$tag.'(?:\s.*)?>(.+)'.$endtag.'#isU', $_body, $found); + if ($ct>0) + { + //error_log(__METHOD__.__LINE__.array2string($found[0])); + // only replace what we have found + $_body = str_ireplace($found[0],'',$_body); + } +/* $_body = preg_replace('~<'.$tag.'[^>]*?>(.*?)'.$endtag.'~simU','',$_body); +*/ // remove left over tags, unfinished ones, and so on $_body = preg_replace('~<'.$tag.'[^>]*?>~si','',$_body); $_body = preg_replace('~'.$endtag.'~','',$_body);