Documentation

CBXSanitizer Class

CBXSanitizer class is used to clean user-inputted HTML text from permitted tags and attributes that are not included into the "whitelist".

Class methods

Method Description Available from version
AddTags Adds tags and attributes to the whitelist. 11.5.5
ApplyHtmlSpecChars Executes function htmlspecialchars() for text and tags excluded from whitelist. 11.5.5
DelAllTags Deletes all tags from the whitelist. 11.5.5
DeleteSanitizedTags Deletes tags that are excluded from the whitelist. 11.5.5
DelTags Deletes tags from the whitelist. 11.5.5
GetTags Returns list of permitted tags ad attributes as formatted text.
SanitizeHtml Filters HTML.
SetLevel Automatically fills the list of permitted tags according to the selected levels.
UpdateTags Updates tags and attributes included into whitelist. 11.5.5

Example

$Sanitizer = new CBXSanitizer;

$Sanitizer->AddTags( array (
                  'a' = > array('href','id','style','alt'...),
                  'br' => array(),
                     .... ));

$pureHtml = $Sanitizer->SanitizeHtml($html);
либо
$Sanitizer = new CBXSanitizer;

$Sanitizer->SetLevel(CBXSanitizer::SECURE_LEVEL_MIDDLE);

$pureHtml = $Sanitizer->SanitizeHtml($html);


© «Bitrix24», 2001-2024
Up