• Модуль: scale
  • Путь к файлу: ~/bitrix/modules/scale/lib/actionsdata.php
  • Класс: BitrixScaleActionsData
  • Вызов: ActionsData::checkCondition
static function checkCondition(string $operand1, string $operator, string $operand2): bool
{
	$allowedOperators = ['==='];

	if(!in_array($operator, $allowedOperators))
	{
		throw new ArgumentOutOfRangeException('This "operator" is not allowed');
	};

	$allowedOperandRegex = '/^[0-9a-zA-Z_:-'"]+$/i';

	if(!preg_match($allowedOperandRegex, $operand1))
	{
		return false;
	}

	if(!preg_match($allowedOperandRegex, $operand2))
	{
		throw new ArgumentOutOfRangeException('This "operand2" is wrong');
	}

	return eval("return ('{$operand1}' {$operator} '{$operand2}');");
}