Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/ilovecveti.ru/bitrix/modules/yandex.market/lib/utils/ |
Upload File : |
<?php namespace Yandex\Market\Utils; class XmlValue { protected static $allowedEntities = [ '&' => true, ' ' => true, '<' => true, '>' => true, '"' => true, ''' => true, ]; protected static $replaceEntities = [ ' ' => ' ', ' ' => ' ', ' ' => ' ', '–' => '-', '—' => '-', ]; public static function escape($value) { static $encoding = null; if ($encoding === null) { $encoding = defined('BX_UTF') ? 'UTF-8' : 'ISO-8859-1'; } $value = preg_replace_callback("/&[a-z]{4,5};/", [static::class, 'applyReplace'], $value); // restore valid chars $value = htmlspecialchars($value, ENT_NOQUOTES|ENT_XML1, $encoding, false); // apply special chars (no need quotes, simplexml restores original quotes) $value = preg_replace_callback("/&([^;]*;)/", [static::class, 'applyEscape'], $value); // escape not valid entities $value = preg_replace("/[\x1-\x8\xB-\xD\xE-\x1F]/", '', $value); // remove special chars return $value; } protected static function applyReplace(array $matches) { return isset(static::$replaceEntities[$matches[0]]) ? static::$replaceEntities[$matches[0]] : $matches[0]; } protected static function applyEscape(array $matches) { return isset(static::$allowedEntities[$matches[0]]) ? $matches[0] : ('&' . $matches[1]); } }