math equation return warning: math: illegal character for : {math equation="max(x, y)" x=$x y=$y}

This commit is contained in:
Pavel Kochman
2022-02-04 21:03:25 +01:00
committed by Simon Wisselink
parent 99085d8dc6
commit 9f47b059ed
2 changed files with 17 additions and 1 deletions

View File

@@ -69,7 +69,7 @@ function smarty_function_math($params, $template)
// Adapted from https://www.php.net/manual/en/function.eval.php#107377
$number = '(?:\d+(?:[,.]\d+)?|pi|π)'; // What is a number
$functionsOrVars = '((?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))';
$operators = '[+\/*\^%-]'; // Allowed math operators
$operators = '[,+\/*\^%-]'; // Allowed math operators
$regexp = '/^(('.$number.'|'.$functionsOrVars.'|('.$functionsOrVars.'\s*\((?1)+\)|\((?1)+\)))(?:'.$operators.'(?1))?)+$/';
if (!preg_match($regexp, $equation)) {