Single quote in contribution amount label breaks text receipt emails
Steps to reproduce:
- Configure a confirmation page to use contribution amounts without a price set.
- Have a single quote in a Contribution Label. Example: "Provides a family with a month's worth of groceries"
- Make a contribution selecting that contribution option
Expected result:
- Contribution receipt email is sent
Actual result:
- PHP error:
"Message was not parsed due to invalid smarty syntax : Smarty error: [in evaluated template line 55]: syntax error: (secure mode) 's' not allowed in if statement (Smarty_Compiler.class.php, line 1398)"
Can also be triggered by finding the contribution and sending a receipt email.
Full PHP error details from ConfigAndLog: https://lab.civicrm.org/-/snippets/86
Observations:
- This line in the default Contributions - Receipt (on-line) text template seems to be the issue:
{ts}Amount{/ts}: {contribution.total_amount} {if '{contribution.amount_level}'} - {contribution.amount_level}{/if}
- Adding
{assign var="contributionAmountLevel" value="{contribution.amount_level}"}
and then changing that line to{ts}Amount{/ts}: {contribution.total_amount} {if $contributionAmountLevel} - {contribution.amount_level}{/if}
is a workaround - Doesn't seem to be an issue if a Price Set is used where the label has the same character.
- I was able to reproduce on 5.59.2, 5.58.1, 5.56.2, 5.49.5
Edited by chrisgaraffa