Chris PeBenito 696b41
Chris PeBenito 696b41
/**
Chris PeBenito 696b41
 * Smarty shared plugin
Chris PeBenito 696b41
 * @package Smarty
Chris PeBenito 696b41
 * @subpackage plugins
Chris PeBenito 696b41
 */
Chris PeBenito 696b41
Chris PeBenito 696b41
Chris PeBenito 696b41
/**
Chris PeBenito 696b41
 * escape_special_chars common function
Chris PeBenito 696b41
 *
Chris PeBenito 696b41
 * Function: smarty_function_escape_special_chars
Chris PeBenito 696b41
 * Purpose:  used by other smarty functions to escape
Chris PeBenito 696b41
 *           special chars except for already escaped ones
Chris PeBenito 696b41
 * @param string
Chris PeBenito 696b41
 * @return string
Chris PeBenito 696b41
 */
Chris PeBenito 696b41
function smarty_function_escape_special_chars($string)
Chris PeBenito 696b41
{
Chris PeBenito 696b41
    if(!is_array($string)) {
Chris PeBenito 696b41
        $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
Chris PeBenito 696b41
        $string = htmlspecialchars($string);
Chris PeBenito 696b41
        $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string);
Chris PeBenito 696b41
    }
Chris PeBenito 696b41
    return $string;
Chris PeBenito 696b41
}
Chris PeBenito 696b41
Chris PeBenito 696b41
/* vim: set expandtab: */
Chris PeBenito 696b41
Chris PeBenito 696b41
?>