-
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
Chained modifiers, unexpected results. #327
Comments
In the compiled tpl, the first case is compiled as:
We can see from this that |
I've attached the whole compiled tpl of the test script above for reference |
Any results of modifying an assignment is an undefined behavior. |
If you absolutely want to do it, please try the v3 syntax |
This is a bug on chained modifier when last modifier parameter is a signed value. I will fix that asap |
AnrDaemon |
The bugfix is now in the master branch and will later be included in 3.1.22 |
The first case below comes from a Smarty2 script which works fine, but once applied to Smarty3.1.x and up it breaks giving an unexpected value.
The issue stems from the -4 being used in substr and the cat after it. If the - sign is removed, the functions works as expected, albeit the other way around.
Is this a Smarty bug?
The following is a simple test script with expected and actual results.
{assign var="aFile" value="somefile.xyz"|substr:0:-4|cat:".ext"}
<!-- Result expected: somefile.ext -->
<!-- Actual result: somefile -->
{$aFile}
{assign var="aFile" value="somefile.xyz"|substr:0:4|cat:".ext"}
<!-- Result expected: some.ext -->
<!-- Actual result: some.ext -->
{$aFile}
{assign var="aFile" value=("somefile.xyz"|substr:0:-4)|cat:".ext"}
<!-- Result expected: somefile.ext -->
<!-- Actual result: somefile.ext -->
{$aFile}
{assign var="aFile" value="somefile.xyz"|substr:0:-4}
{assign var="aFile" value=$aFile|cat:".ext"}
<!-- Result expected: somefile.ext -->
<!-- Actual result: somefile.ext -->
{$aFile}
{assign var="aFile" value="somefile.xyz"|substr:0:-(4)|cat:".ext"}
<!-- Result expected: somefile.ext -->
<!-- Actual result: somefile -->
{$aFile}
{assign var="aFile" value="somefile.xyz"|substr:0:(-4)|cat:".ext"}
<!-- Result expected: somefile.ext -->
<!-- Actual result: somefile.ext -->
{$aFile}
{assign var="aFile" value=-4|cat:".ext"}
<!-- Result expected: -4.ext -->
<!-- Actual result: -4.ext -->
{$aFile}
{assign var="aFile" value=-4-4|cat:".ext"}
<!-- Result expected: -8.ext -->
<!-- Actual result: -8.ext -->
{$aFile}
Above code contained here:
test.tpl.txt
The text was updated successfully, but these errors were encountered: