From: <ny...@us...> - 2007-10-13 15:52:59
|
Update of /cvsroot/tikiwiki/tiki In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32346 Modified Files: tiki-editpage.php Log Message: [FIX] special chars in wiki page edition mode: remove htmldecode() call (and enhance the function, just in case) - htmldecode was used only in edition mode and in some cases. It is not needed, as in display mode - the use of html_entity_decode is far better than using ISO-8859-15 functions and converting it back to UTF-8 (some special chars are loosed), but this is only possible with PHP 5+ (so, the old code has been kept for older versions of PHP) Index: tiki-editpage.php =================================================================== RCS file: /cvsroot/tikiwiki/tiki/tiki-editpage.php,v retrieving revision 1.180 retrieving revision 1.181 diff -u -d -r1.180 -r1.181 --- tiki-editpage.php 12 Oct 2007 07:55:27 -0000 1.180 +++ tiki-editpage.php 13 Oct 2007 15:53:01 -0000 1.181 @@ -687,8 +687,6 @@ $pageLang = ""; } $smarty->assign('lang', $pageLang); - -if ($prefs['feature_wysiwyg'] == 'n' or $_SESSION['wysiwyg'] != 'y') $edit_data =& htmldecode($edit_data); $smarty->assign('pagedata',$edit_data); // apply the optional post edit filters before preview @@ -720,9 +718,17 @@ } function htmldecode($string) { - $string = strtr($string, array_flip(get_html_translation_table(HTML_ENTITIES))); - $string = preg_replace("/&#([0-9]+);/me", "chr('\\1')", $string); - return $string; + if ( version_compare(phpversion(), '5', '>=') ) { + // Use html_entity_decode with UTF-8 only with PHP5 or later, since + // this function was available in PHP4 but _without_ multi-byte charater sets support + $string = html_entity_decode($string, ENT_COMPAT, 'utf-8'); + return $string; + } else { + // For compatibility purposes with php < 5 + $string = strtr($string, array_flip(get_html_translation_table(HTML_ENTITIES))); + $string = preg_replace("/&#([0-9]+);/me", "chr('\\1')", $string); + return recode_string('iso-8859-15..utf-8', $string); + } } |