diff --git a/src/codegen.inc.php b/src/codegen.inc.php index f40ba2a..4cba5b0 100644 --- a/src/codegen.inc.php +++ b/src/codegen.inc.php @@ -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