Added Canvas 1.1.0, originally not under SCM so no historical development records...
[canvas.git] / library / smarty / plugins / shared.escape_special_chars.php
blob4ea0979c29243e980b098e7824d3882cfe1881cf
1 <?php
2 /**
3 * Smarty shared plugin
4 * @package Smarty
5 * @subpackage plugins
6 */
9 /**
10 * escape_special_chars common function
12 * Function: smarty_function_escape_special_chars<br>
13 * Purpose: used by other smarty functions to escape
14 * special chars except for already escaped ones
15 * @author Monte Ohrt <monte at ohrt dot com>
16 * @param string
17 * @return string
19 function smarty_function_escape_special_chars($string)
21 if(!is_array($string)) {
22 $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
23 $string = htmlspecialchars($string);
24 $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string);
26 return $string;
29 /* vim: set expandtab: */