%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 3.147.49.252 Web Server : Apache/2.4.52 (Ubuntu) System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 User : www-root ( 1010) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/sender/lib/security/ |
Upload File : |
<?php /** * Bitrix Framework * @package bitrix * @subpackage sender * @copyright 2001-2012 Bitrix */ namespace Bitrix\Sender\Security; use Bitrix\Main\Loader; use Bitrix\Fileman; /** * Class Sanitizer * @package Bitrix\Sender\Security */ class Sanitizer { /** * Clean html. * * @param string $html Html text. * @param string $previousHtml Previous html text. * @param User $user User instance. * @return string|null */ public static function sanitizeHtml($html, $previousHtml = '', User $user = null) { $html = self::cleanHtml($html); return self::removePhp($html, $previousHtml, $user); } /** * Clean html. * * @param string $html Html text. * @return string|null */ public static function cleanHtml($html) { if (!$html || !is_string($html)) { return null; } $html = preg_replace('/<(script|iframe)(.*?)>(.*?)(<\\/\\1.*?>)/is', '', $html); if (Loader::includeModule('fileman')) { $html = Fileman\Block\Content\SliceConverter::sanitize($html); } return $html; } /** * Fix replaced style tags and attributes. * * @param string $html Html text. * @return string|null */ public static function fixReplacedStyles($html) { return str_replace( [ '<st yle ', '<st yle ', ' st yle="',' st yle="', ' st yle=\'',' st yle=\'', ], [ '<style ', '<style ', ' style="',' style="', ' style=\'',' style=\'', ], $html ); } /** * Fix template styles. * * @param string $html Html text. * @return string|null */ public static function fixTemplateStyles($html) { $html = str_replace('<body class="">{}', '<body class="">', $html); $html = str_replace('</style>{}', '</style>', $html); if (!$html) { return $html; } $html = preg_replace('/<st yle.*?>(.*?)<\/style>/is', '</style>', $html); $html = preg_replace('/<\/style>([\s]*?)<\/style>/is', '</style>', $html); return $html; } /** * Remove php from string with checking operations `edit_php` and `lpa_template_edit`. * * @param string $string String. * @param User $user User instance. * @return bool */ public static function removePhp($string = '', $previousString, User $user = null) { $user = $user ?: User::current(); Loader::includeModule('fileman'); return Fileman\Block\EditorMail::removePhpFromHtml( $string, $previousString, $user->canEditPhp(), $user->canUseLpa() ); } }