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/rospirotorg.ru/bitrix/modules/security/classes/general/ |
Upload File : |
<?php class CSecurityHtmlEntity { private static $htmlMnemonics = array( "html" => array( "/:/i", "/&tab;/i", "/&newline;/i" ), "text" => array( ":", "\r", "\n" ), ); /** * Decode characters presented as { * * @param string $entity * @return string */ protected static function decodeCb($entity) { $ad = $entity[2]; if($ad == ';') $ad=""; $num = intval($entity[1]); return chr($num).$ad; } /** * Decode characters presented as « * * @param string $entity * @return string */ protected static function decodeCbHex($entity) { $ad = $entity[2]; if($ad==';') $ad=""; $num = intval(hexdec($entity[1])); return chr($num).$ad; } /** * Decodes string from html codes &#***; but only a-zA-Z:().=, because only these are used in auditors * One pass! * * @param string $string * @return string */ protected static function decode($string) { $string = preg_replace_callback("/\&\#(\d+)([^\d]|$)/is", array(__CLASS__, "decodeCb"), $string); $string = preg_replace_callback("/\&\#x([\da-f]+)([^\da-f]|$)/is", array(__CLASS__, "decodeCbHex"), $string); $string = preg_replace(self::$htmlMnemonics["html"], self::$htmlMnemonics["text"],$string); return $string; } /** * Recursive decodes string from html codes &#***; but only a-zA-Z:().=, because only these are used in auditors * * @param string $pString * @return string */ public static function decodeString($pString) { $strY = $pString; $str1 = ""; while($str1 <> $strY) { $str1 = $strY; $strY = self::decode($strY); $strY = str_replace("\x00", "", $strY); $strY = preg_replace("/\&\#0+(;|([^\d;]))/is", "\\2", $strY); $strY = preg_replace("/\&\#x0+(;|([^\da-f;]))/is", "\\2", $strY); } return $str1; } }