1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Класс CBXSanitizer

Открытые члены

 __construct ()
 allowAttributes (array $attrs)
 AddTags ($arTags)
 UpdateTags ($arTags)
 DelTags ($arTagNames)
 DeleteAttributes (array $arDeleteAttrs)
 DelAllTags ()
 ApplyDoubleEncode ($bApply=true)
 ApplyHtmlSpecChars ($bApply=true)
 DeleteSanitizedTags ($bApply=true)
 SetLevel ($secLevel)
 GetTags ()
 SanitizeHtml ($html)
 Decode ($str)
 setDelTagsWithContent (array $tags)
 getDelTagsWithContent ()

Открытые статические члены

static SetTags ($arTags)
static Sanitize ($html, $secLevel='HIGH', $htmlspecialchars=true, $delTags=true)

Поля данных

const SECURE_LEVEL_CUSTOM = 0
const SECURE_LEVEL_HIGH = 1
const SECURE_LEVEL_MIDDLE = 2
const SECURE_LEVEL_LOW = 3
const TABLE_TOP = 0
const TABLE_CAPT = 1
const TABLE_GROUP = 2
const TABLE_ROWS = 3
const TABLE_COLS = 4
const ACTION_DEL = 'del'
const ACTION_ADD = 'add'
const ACTION_DEL_WITH_CONTENT = 'del_with_content'

Защищенные члены

 IsValidAttr (&$arAttr)
 encodeAttributeValue (array $attr)
 splitHtml ($html)
 extractAttributes (string $attrData)
 processAttributes (string $attrData, string $currTag)
 CleanTable (&$seg, &$openTagsStack, $segIndex, $delTextBetweenTags=true)
 _decode_cb ($in)
 _decode_cb_hex ($in)
 _decode ($str)

Защищенные данные

 $arHtmlTags = array()
 $bHtmlSpecChars = true
 $bDelSanitizedTags = true
 $bDoubleEncode = true
 $secLevel = self::SECURE_LEVEL_HIGH
 $additionalAttrs = array()
 $arNoClose
 $localAlph
 $arTableTags
 $delTagsWithContent = ['script', 'style']

Статические защищенные данные

static $arOldTags = array()

Подробное описание

CBXSanitizer Class to cut all tags and attributies from html not contained in white list

Example to use: $Sanitizer = new CBXSanitizer;

$Sanitizer->SetLevel(CBXSanitizer::SECURE_LEVEL_MIDDLE); or $Sanitizer->AddTags( array ( 'a' = > array('href','id','style','alt'...), 'br' => array(), .... ));

$Sanitizer->SanitizeHtml($html);

См. определение в файле sanitizer.php строка 22

Конструктор(ы)

◆ __construct()

__construct ( )

CBXSanitizer constructor.

См. определение в файле sanitizer.php строка 81

Методы

◆ _decode()

_decode ( $str)
protected

См. определение в файле sanitizer.php строка 1063

◆ _decode_cb()

_decode_cb ( $in)
protected

См. определение в файле sanitizer.php строка 1037

◆ _decode_cb_hex()

_decode_cb_hex ( $in)
protected

См. определение в файле sanitizer.php строка 1049

◆ AddTags()

AddTags ( $arTags)

Adds HTML tags and attributes to white list

Аргументы
mixed$arTagsarray('tagName1' = > array('attribute1','attribute2',...), 'tagName2' => ........)
Возвращает
int count of added tags

См. определение в файле sanitizer.php строка 136

◆ allowAttributes()

allowAttributes ( array $attrs)

Allow additional attributes in html.

Аргументы
array$attrsAdditional attrs Example: $sanitizer->allowAttributes(array( 'aria-label' => array( 'tag' => function($tag) { return ($tag == 'div'); }, 'content' => function($value) { return !preg_match("#[^\\s\\w\\-\\#\\.;]#iu", $value); } ) ));
Возвращает
void

См. определение в файле sanitizer.php строка 117

◆ ApplyDoubleEncode()

ApplyDoubleEncode ( $bApply = true)

If is turned off Sanitizer will not encode existing html entities, in text blocks. The default is to convert everything. http://php.net/manual/ru/function.htmlspecialchars.php (double_encode)

Аргументы
bool$bApplytrue|false

См. определение в файле sanitizer.php строка 218

◆ ApplyHtmlSpecChars()

ApplyHtmlSpecChars ( $bApply = true)

Apply or not function htmlspecialchars to filtered tags and text !WARNING! if DeleteSanitizedTags = false and ApplyHtmlSpecChars = false html will not be sanitized!

Аргументы
bool$bApplytrue|false

См. определение в файле sanitizer.php строка 233

◆ CleanTable()

CleanTable ( & $seg,
& $openTagsStack,
$segIndex,
$delTextBetweenTags = true )
protected

function CleanTable Check if table code is valid, and corrects. If need deletes all text and tags between diferent table tags if $delTextBetweenTags=true. Checks if where are open tags from upper level if not - self-distructs.

См. определение в файле sanitizer.php строка 935

◆ Decode()

Decode ( $str)

Decodes text from codes like &#***, html-entities wich may be coded several times;

Аргументы
string$str
Возвращает
string decoded

См. определение в файле sanitizer.php строка 1018

◆ DelAllTags()

DelAllTags ( )

Deletes all tags from white list

См. определение в файле sanitizer.php строка 205

◆ DeleteAttributes()

DeleteAttributes ( array $arDeleteAttrs)
Аргументы
array$arDeleteAttrs

См. определение в файле sanitizer.php строка 191

◆ DeleteSanitizedTags()

DeleteSanitizedTags ( $bApply = true)

Delete or not filtered tags !WARNING! if DeleteSanitizedTags = false and ApplyHtmlSpecChars = false html will not be sanitized!

Аргументы
bool$bApplytrue|false

См. определение в файле sanitizer.php строка 252

◆ DelTags()

DelTags ( $arTagNames)

Deletes tags from white list

Аргументы
mixed$arTagNamesarray('tagName1','tagname2',...)
Возвращает
int count of deleted tags

См. определение в файле sanitizer.php строка 168

◆ encodeAttributeValue()

encodeAttributeValue ( array $attr)
protected

См. определение в файле sanitizer.php строка 477

◆ extractAttributes()

extractAttributes ( string $attrData)
protected

См. определение в файле sanitizer.php строка 884

◆ getDelTagsWithContent()

getDelTagsWithContent ( )
Возвращает
array

См. определение в файле sanitizer.php строка 1081

◆ GetTags()

GetTags ( )

Returns allowed tags and attributies

Возвращает
string

См. определение в файле sanitizer.php строка 510

◆ IsValidAttr()

IsValidAttr ( & $arAttr)
protected

См. определение в файле sanitizer.php строка 410

◆ processAttributes()

processAttributes ( string $attrData,
string $currTag )
protected

См. определение в файле sanitizer.php строка 898

◆ Sanitize()

Sanitize ( $html,
$secLevel = 'HIGH',
$htmlspecialchars = true,
$delTags = true )
static

См. определение в файле sanitizer.php строка 546

◆ SanitizeHtml()

SanitizeHtml ( $html)

Erases, or HtmlSpecChares Tags and attributies wich not contained in white list from inputted HTML

Аргументы
string$htmlDirty HTML
Возвращает
string filtered HTML

count($this->arHtmlTags[$seg[$i]['tagName']]) || fix:

См. определение в файле sanitizer.php строка 598

◆ setDelTagsWithContent()

setDelTagsWithContent ( array $tags)
Аргументы
array$tags

См. определение в файле sanitizer.php строка 1073

◆ SetLevel()

SetLevel ( $secLevel)

Sets security level from predefined

Аргументы
int$secLevel{ CBXSanitizer\SECURE_LEVEL_HIGH | CBXSanitizer\SECURE_LEVEL_MIDDLE | CBXSanitizer\SECURE_LEVEL_LOW }

См. определение в файле sanitizer.php строка 266

◆ SetTags()

SetTags ( $arTags)
static

См. определение в файле sanitizer.php строка 532

◆ splitHtml()

splitHtml ( $html)
protected

Split html to tags and simple text chunks

Аргументы
string$html
Возвращает
array

См. определение в файле sanitizer.php строка 570

◆ UpdateTags()

UpdateTags ( $arTags)
См. также
AddTags()

См. определение в файле sanitizer.php строка 158

Поля

◆ $additionalAttrs

$additionalAttrs = array()
protected

См. определение в файле sanitizer.php строка 53

◆ $arHtmlTags

$arHtmlTags = array()
protected

См. определение в файле sanitizer.php строка 48

◆ $arNoClose

$arNoClose
protected
Инициализатор
'br','hr','img','area','base',
'basefont','col','frame','input',
'isindex','link','meta','param'
)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804

См. определение в файле sanitizer.php строка 54

◆ $arOldTags

$arOldTags = array()
staticprotected

См. определение в файле sanitizer.php строка 46

◆ $arTableTags

$arTableTags
protected
Инициализатор
'table' => self::TABLE_TOP,
'caption' => self::TABLE_CAPT,
'thead' => self::TABLE_GROUP,
'tfoot' => self::TABLE_GROUP,
'tbody' => self::TABLE_GROUP,
'tr' => self::TABLE_ROWS,
'th' => self::TABLE_COLS,
'td' => self::TABLE_COLS
)

См. определение в файле sanitizer.php строка 61

◆ $bDelSanitizedTags

$bDelSanitizedTags = true
protected

См. определение в файле sanitizer.php строка 50

◆ $bDoubleEncode

$bDoubleEncode = true
protected

См. определение в файле sanitizer.php строка 51

◆ $bHtmlSpecChars

$bHtmlSpecChars = true
protected

См. определение в файле sanitizer.php строка 49

◆ $delTagsWithContent

$delTagsWithContent = ['script', 'style']
protected

См. определение в файле sanitizer.php строка 76

◆ $localAlph

$localAlph
protected

См. определение в файле sanitizer.php строка 59

◆ $secLevel

$secLevel = self::SECURE_LEVEL_HIGH
protected

См. определение в файле sanitizer.php строка 52

◆ ACTION_ADD

const ACTION_ADD = 'add'

См. определение в файле sanitizer.php строка 39

◆ ACTION_DEL

const ACTION_DEL = 'del'

См. определение в файле sanitizer.php строка 38

◆ ACTION_DEL_WITH_CONTENT

const ACTION_DEL_WITH_CONTENT = 'del_with_content'

См. определение в файле sanitizer.php строка 40

◆ SECURE_LEVEL_CUSTOM

const SECURE_LEVEL_CUSTOM = 0

Security levels

См. определение в файле sanitizer.php строка 27

◆ SECURE_LEVEL_HIGH

const SECURE_LEVEL_HIGH = 1

См. определение в файле sanitizer.php строка 28

◆ SECURE_LEVEL_LOW

const SECURE_LEVEL_LOW = 3

См. определение в файле sanitizer.php строка 30

◆ SECURE_LEVEL_MIDDLE

const SECURE_LEVEL_MIDDLE = 2

См. определение в файле sanitizer.php строка 29

◆ TABLE_CAPT

const TABLE_CAPT = 1

См. определение в файле sanitizer.php строка 33

◆ TABLE_COLS

const TABLE_COLS = 4

См. определение в файле sanitizer.php строка 36

◆ TABLE_GROUP

const TABLE_GROUP = 2

См. определение в файле sanitizer.php строка 34

◆ TABLE_ROWS

const TABLE_ROWS = 3

См. определение в файле sanitizer.php строка 35

◆ TABLE_TOP

const TABLE_TOP = 0

См. определение в файле sanitizer.php строка 32


Объявления и описания членов класса находятся в файле: