Documentation

SetLevel

 void 
CBXSanitizer::SetLevel(
 bool secLevel
)

The method fills the array of permitted tags to the selected level.

The method returns nothing.

CBXSanitizer::SetLevel() can be called only as the initialized object method and not as static method of CBXSanitizer class.

Parameters

ParameterDescription
secLevel

Can have the following values:

  • CBXSanitizer::SECURE_LEVEL_HIGH
  • CBXSanitizer::SECURE_LEVEL_MIDDLE
  • CBXSanitizer::SECURE_LEVEL_LOW

The following tags and attributes will be added into the whitelist:

      CBXSanitizer::SECURE_LEVEL_HIGH

        $arTags = array(
            'b'     => array(),
            'br'    => array(),
            'big'   => array(),
            'blockquote'    => array(),
            'code'    => array(),
            'del'   => array(),
            'dt'    => array(),
            'dd'    => array(),
            'font'    => array(),
            'h1'    => array(),
            'h2'    => array(),
            'h3'    => array(),
            'h4'    => array(),
            'h5'    => array(),
            'h6'    => array(),
            'hr'    => array(),
            'i'     => array(),
            'ins'   => array(),
            'li'    => array(),
            'ol'    => array(),
            'p'     => array(),
            'small'   => array(),
            's'     => array(),
            'sub'   => array(),
            'sup'   => array(),
            'strong'  => array(),
            'pre'   => array(),
            'u'     => array(),
            'ul'    => array()
          );
      
      CBXSanitizer::SECURE_LEVEL_MIDDLE

        $arTags = array(
            'a'     => array('href', 'title','name','alt'),
            'b'     => array(),
            'br'    => array(),
            'big'   => array(),
            'code'    => array(),
            'caption' => array(),
            'del'   => array('title'),
            'dt'    => array(),
            'dd'    => array(),
            'font'    => array('color','size'),
            'color'   => array(),
            'h1'    => array(),
            'h2'    => array(),
            'h3'    => array(),
            'h4'    => array(),
            'h5'    => array(),
            'h6'    => array(),
            'hr'    => array(),
            'i'     => array(),
            'img'   => array('src','alt','height','width','title'),
            'ins'   => array('title'),
            'li'    => array(),
            'ol'    => array(),
            'p'     => array(),
            'pre'   => array(),
            's'     => array(),
            'small'   => array(),
            'strong'  => array(),
            'sub'   => array(),
            'sup'   => array(),
            'table'   => array('border','width'),
            'tbody'   => array('align','valign'),
            'td'    => array('width','height','align','valign'),
            'tfoot'   => array('align','valign'),
            'th'    => array('width','height'),
            'thead'   => array('align','valign'),
            'tr'    => array('align','valign'),
            'u'     => array(),
            'ul'    => array()
      
      CBXSanitizer::SECURE_LEVEL_LOW

        $arTags = 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'),
            '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')
          );

      

Examples

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


© «Bitrix24», 2001-2024
Up