Passing filter args as is if they are not starting with [ or {

This commit is contained in:
Pavel Shevaev 2023-03-22 14:57:51 +03:00
parent 9963afe0a9
commit 496bf3aabf
1 changed files with 6 additions and 3 deletions

View File

@ -115,13 +115,16 @@ function apply_value_filters($field_name, array $tokens, $val, $add_assoc_check
if(function_exists($filter_func))
{
$args = array();
if($args_json)
$args = null;
if($args_json && (strpos($args_json, '[') === 0 || strpos($args_json, '{') === 0))
{
$args = json_decode($args_json, true);
if(!is_array($args))
throw new Exception("Bad filter args: $args_json");
throw new Exception("Bad filter '$token' args: '$args_json'");
}
else
$args = $args_json;
if($add_assoc_check)
$str = "(\$assoc ? $filter_func($str, '$field_name', \$this, " . str_replace("\n", "", var_export($args, true)) . ") : $str)";
else