Bugfix/rand without param v3 (#796)

* Fixed use of `rand()` without a parameter in math function (for v3.1)
Fixes #794

* Add change in regex for PRCE (PHP < 7.3)

* Add unit tests and correctly set PHP supported versions

* Drop PHP5.2 from CI workflows because it cannot be build anymore

* Fix CI workflow for PHP7.2 and up

* re-add compose packages cache with specific key

* Exclude unit test files from git export

* prevent double CI workflows in PRs
This commit is contained in:
Simon Wisselink
2022-09-12 16:03:27 +02:00
committed by GitHub
parent b3ade90dec
commit 25051e6e88
18 changed files with 259 additions and 3 deletions

View File

@@ -70,7 +70,7 @@ function smarty_function_math($params, $template)
$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
$regexp = '/^(('.$number.'|'.$functionsOrVars.'|('.$functionsOrVars.'\s*\((?1)+\)|\((?1)+\)))(?:'.$operators.'(?1))?)+$/';
$regexp = '/^(('.$number.'|'.$functionsOrVars.'|('.$functionsOrVars.'\s*\((?1)*\)|\((?1)*\)))(?:'.$operators.'(?1))?)+$/';
if (!preg_match($regexp, $equation)) {
trigger_error("math: illegal characters", E_USER_WARNING);