X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=inc%2Fsmarty%2Fplugins%2Fshared.escape_special_chars.php;fp=inc%2Fsmarty%2Fplugins%2Fshared.escape_special_chars.php;h=25b74de27e4260a155a7994fa5b01bee1fa6eeee;hb=e586807dafc64c3fe152ab518599e6cf3f0f84e1;hp=0000000000000000000000000000000000000000;hpb=bc13d5d6e1834068f8b690c32bba114e352dacdd;p=mirrors%2FKyberia-bloodline.git diff --git a/inc/smarty/plugins/shared.escape_special_chars.php b/inc/smarty/plugins/shared.escape_special_chars.php new file mode 100644 index 0000000..25b74de --- /dev/null +++ b/inc/smarty/plugins/shared.escape_special_chars.php @@ -0,0 +1,30 @@ + + * Purpose: used by other smarty functions to escape + * special chars except for already escaped ones + * @param string + * @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; +} + +/* vim: set expandtab: */ + +?>