mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
Fix Fenom::isAllowedFunction()
- Checks if function in `ini_get('disable_functions')` - Replace `is_callable()` to `function_exists()` to ignore invokable classes
This commit is contained in:
parent
8fb0a70311
commit
79283c6f7f
@ -200,6 +200,11 @@ class Fenom
|
|||||||
"implode" => 1
|
"implode" => 1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string[] the disabled functions by `disable_functions` PHP's option
|
||||||
|
*/
|
||||||
|
protected $_disabled_funcs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array[] of compilers and functions
|
* @var array[] of compilers and functions
|
||||||
*/
|
*/
|
||||||
@ -769,16 +774,24 @@ class Fenom
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $function
|
* Checks if is allowed PHP function for using in templates.
|
||||||
|
*
|
||||||
|
* @param string $function the function name
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isAllowedFunction($function)
|
public function isAllowedFunction($function)
|
||||||
{
|
{
|
||||||
if ($this->_options & self::DENY_NATIVE_FUNCS) {
|
$function = (string) $function;
|
||||||
return isset($this->_allowed_funcs[$function]);
|
if (!is_array($this->_disabled_funcs)) {
|
||||||
} else {
|
$disabled = ini_get('disable_functions');
|
||||||
return is_callable($function);
|
$this->_disabled_funcs = empty($disabled) ? [] : explode(',', $disabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->_options & self::DENY_NATIVE_FUNCS) {
|
||||||
|
return isset($this->_allowed_funcs[$function]) && !in_array($function, $this->_disabled_funcs, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return function_exists($function) && !in_array($function, $this->_disabled_funcs, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user