From 6fc07742f8fca9d32db23243d374ea27e8ee4c1e Mon Sep 17 00:00:00 2001 From: rvelices Date: Thu, 20 Jun 2013 03:38:47 +0000 Subject: smarty 3 - first pass for tests git-svn-id: http://piwigo.org/svn/trunk@23384 68402e56-0260-453c-a942-63ccdbb3a9ee --- .../libs/plugins/shared.escape_special_chars.php | 68 ++++++++++++++-------- 1 file changed, 44 insertions(+), 24 deletions(-) (limited to 'include/smarty/libs/plugins/shared.escape_special_chars.php') diff --git a/include/smarty/libs/plugins/shared.escape_special_chars.php b/include/smarty/libs/plugins/shared.escape_special_chars.php index c07ce31be..d2609b674 100644 --- a/include/smarty/libs/plugins/shared.escape_special_chars.php +++ b/include/smarty/libs/plugins/shared.escape_special_chars.php @@ -1,31 +1,51 @@ - * Purpose: used by other smarty functions to escape - * special chars except for already escaped ones - * @author Monte Ohrt - * @param string - * @return string + * @package Smarty + * @subpackage PluginsShared */ -function smarty_function_escape_special_chars($string) -{ - if(!is_array($string)) { - $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); - $string = htmlspecialchars($string); - $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string); - } - return $string; -} -/* vim: set expandtab: */ +if (version_compare(PHP_VERSION, '5.2.3', '>=')) { + /** + * escape_special_chars common function + * + * Function: smarty_function_escape_special_chars
+ * Purpose: used by other smarty functions to escape + * special chars except for already escaped ones + * + * @author Monte Ohrt + * @param string $string text that should by escaped + * @return string + */ + function smarty_function_escape_special_chars($string) + { + if (!is_array($string)) { + $string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false); + } + return $string; + } +} else { + /** + * escape_special_chars common function + * + * Function: smarty_function_escape_special_chars
+ * Purpose: used by other smarty functions to escape + * special chars except for already escaped ones + * + * @author Monte Ohrt + * @param string $string text that should by escaped + * @return string + */ + function smarty_function_escape_special_chars($string) + { + if (!is_array($string)) { + $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); + $string = htmlspecialchars($string); + $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); + } + return $string; + } +} -?> +?> \ No newline at end of file -- cgit v1.2.3