Merge branch 'master' into bugfix/706

This commit is contained in:
Simon Wisselink
2022-02-06 22:05:01 +01:00
7 changed files with 25 additions and 4 deletions

View File

@@ -37,6 +37,9 @@ jobs:
- os: ubuntu-latest - os: ubuntu-latest
php-version: "8.0" php-version: "8.0"
compiler: jit compiler: jit
- os: ubuntu-latest
php-version: "8.1"
compiler: jit
steps: steps:
- name: Checkout - name: Checkout

View File

@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- PHP 8.1 deprecation notices in demo/plugins/cacheresource.pdo.php [#706](https://github.com/smarty-php/smarty/issues/706) - PHP 8.1 deprecation notices in demo/plugins/cacheresource.pdo.php [#706](https://github.com/smarty-php/smarty/issues/706)
## [4.1.0] - 2022-02-06
### Added ### Added
- PHP8.1 compatibility [#713](https://github.com/smarty-php/smarty/pull/713) - PHP8.1 compatibility [#713](https://github.com/smarty-php/smarty/pull/713)

View File

@@ -7,7 +7,7 @@ Smarty is a template engine for PHP, facilitating the separation of presentation
Read the [documentation](https://smarty-php.github.io/smarty/) to find out how to use it. Read the [documentation](https://smarty-php.github.io/smarty/) to find out how to use it.
## Requirements ## Requirements
Smarty can be run with PHP 7.1 to PHP 8.0. Smarty can be run with PHP 7.1 to PHP 8.1.
## Installation ## Installation
Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/). Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/).

View File

@@ -2,7 +2,7 @@ What is Smarty?
============== ==============
## Requirements ## Requirements
Smarty can be run with PHP 7.1 to PHP 8.0. Smarty can be run with PHP 7.1 to PHP 8.1.
## Installation ## Installation
Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/). Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/).

View File

@@ -98,7 +98,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '4.0.4'; const SMARTY_VERSION = '4.1.0';
/** /**
* define variable scopes * define variable scopes
*/ */

View File

@@ -69,7 +69,7 @@ function smarty_function_math($params, $template)
// Adapted from https://www.php.net/manual/en/function.eval.php#107377 // Adapted from https://www.php.net/manual/en/function.eval.php#107377
$number = '(?:\d+(?:[,.]\d+)?|pi|π)'; // What is a number $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]*))'; $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))?)+$/'; $regexp = '/^(('.$number.'|'.$functionsOrVars.'|('.$functionsOrVars.'\s*\((?1)+\)|\((?1)+\)))(?:'.$operators.'(?1))?)+$/';
if (!preg_match($regexp, $equation)) { if (!preg_match($regexp, $equation)) {

View File

@@ -52,6 +52,22 @@ class MathTest extends PHPUnit_Smarty
$this->assertEquals($expected, $this->smarty->fetch($tpl)); $this->assertEquals($expected, $this->smarty->fetch($tpl));
} }
public function testMathMaxFunctionParameters()
{
$this->smarty->disableSecurity();
$expected = max(0, 2) . ' -- ' . max(0, 2, 3);
$tpl = $this->smarty->createTemplate('eval:{$x = 0}{$y = 2}{$z = 3}{math equation="max(x, y)" x=$x y=$y} -- {math equation="max(x, y, z)" x=$x y=$y z=$z}');
$this->assertEquals($expected, $this->smarty->fetch($tpl));
}
public function testMathMinFunctionParameters()
{
$this->smarty->disableSecurity();
$expected = min(1, 2) . ' -- ' . min(1, 2, 0);
$tpl = $this->smarty->createTemplate('eval:{$x = 1}{$y = 2}{$z = 0}{math equation="min(x, y)" x=$x y=$y} -- {math equation="min(x, y, z)" x=$x y=$y z=$z}');
$this->assertEquals($expected, $this->smarty->fetch($tpl));
}
public function testSyntaxSin() public function testSyntaxSin()
{ {
$this->smarty->disableSecurity(); $this->smarty->disableSecurity();