-
Notifications
You must be signed in to change notification settings - Fork 715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Smarty 4.0.2 Warning: math: illegal characters #702
Comments
is smarty ready to be used with php8.1.1?
|
Well you go a point there gone close it again sry for disturbing ^^ |
Oops! 😯
|
Gone reopen it again. It isnt an PHP 8.1 error. (had some branching problems where composer didnt downgrade smarty) The problem is comming from line 69-78 in function.math.php
the regex does not support 2 mathematical operations without parentheses. So 2+2+2 wouldnt work but (2+2)+2 would. Dont know if you want to clearify that as a bug but it breaks some stuff on my side |
We're also affected by this issue: <span class="item">{math equation="x - y + 1" x=$smarty.section.i.index y=$nav_start}</span> It is caused by the following check: smarty/libs/plugins/function.math.php Lines 66 to 78 in f707dad
This check was introduced by @wisskid in 4.0.2 (215d81a) to address CVE-2021-29454. |
@Exzelsio A workaround is to replace {* Before *}
{assign var="x" value="1"}
{assign var="y" value="1"}
{math equation="x+y+1" x=$x y=$y assign="yx"}
{* After *}
{$x = 1}
{$y = 1}
{$yx = $x + $y + 1} |
@caugner |
I took some time and inspected all our cases, most would not break. (There were about 20-30 that would break, but I fixed them temporarily). Besides using assigns you can also just use lots of brackets (if you want to stay true to math equalation). X+Z+Y = (X+Z)+y You just have to be careful that the equation still works correctly. |
* fix(math): fix equation regexp Fixes #702.
* fix(math): fix equation regexp Fixes #702.
@wisskid |
@Exzelsio I added your example as a test case locally, and it does not fail: public function testMultipleAdditions()
{
$this->smarty->disableSecurity();
$expected = "6";
$tpl = $this->smarty->createTemplate('eval:{math equation="2 + 2 + 2"}');
$this->assertEquals($expected, $this->smarty->fetch($tpl));
} Please upgrade to Smarty 4.0.4 and test again. |
Hi, I got warnings for the next equations, these equations works fine before the sandbox change
|
Good morning dear Smarty Team,
after updating to PHP 8.1 i get:
Warning: math: illegal characters in vendor/smarty/smarty/libs/plugins/function.math.php on line 76
Here is some sample code when the warning pops up.
Smarty 4.0.2 ( independent from warning testet 3.1.* and 4.0.0)
Php 8.1.1
The text was updated successfully, but these errors were encountered: