- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/format/texthelper.php
- Класс: Bitrix\Crm\Format\TextHelper
- Вызов: TextHelper::sanitizeBbCode
static function sanitizeBbCode($bb, array $excludeFromWhitelist = []): string
{
$bb = (string)$bb;
if (empty($bb))
{
return '';
}
static $whitelist = [
'b', //bold
'i', //italic
'u', //underlined
's', //strike
'list', //ul and ol,
'\*', //* - list item
'user', //mention
'img',
'disk file id',
'url',
];
$pattern =
'#\[(\/?)(?!\b'
. implode('\b|\b', array_diff($whitelist, $excludeFromWhitelist))
. '\b)\w+\b[^\]]*\]#i'
. BX_UTF_PCRE_MODIFIER
;
return preg_replace($pattern, '', $bb);
}