Files
kupshop/class/smarty_plugins/modifier.xml_string.php
2025-08-02 16:30:27 +02:00

13 lines
507 B
PHP

<?php
function smarty_modifier_xml_string($string)
{
$string = html_entity_decode($string, ENT_QUOTES, 'UTF-8');
// beware of the order of search@replace values
// str_replace() replaces left to right, it might replace a previously inserted value when doing multiple replacements
$string = str_replace(['&', '<', '>'], ['&amp;', '&lt;', '&gt;'], $string);
$string = preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $string);
return $string;
}