🩹 dev/core#4149 Change CKEditor 4 default to not encode HTML entities by default which breaks Smarty syntax and prevents use of crmDate function #25681
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change CKEditor 4 default to not encode HTML entities by default which breaks Smarty syntax and prevents use of crmDate function. Looks like this has been a reported problem since 2015, https://civicrm.stackexchange.com/questions/7212/escaping-quotes-in-ckeditor-breaks-smarty-syntax/7213#7213
Overview
User editable Message Templates, the Contact Action: Send an Email and the Contact Action: Print Merge/Document cannot use any Smarty Tokens with the crmDate function because CKEditor 4 unnecessarily HTML encodes single quotes (') and double quotes (").
So if you use a Smarty Token like:
{contribution.receive_date|crmDate:"%E%f %B %Y"}
{contribution.receive_date|crmDate:'%E%f %B %Y'}
When CKEditor 4 parses the HTML it converts this into:
{contribution.receive_date|crmDate:"%E%f %B %Y"}
{contribution.receive_date|crmDate:'%E%f %B %Y'}
Effectively rendering the crmDate function unusable in these situations.
https://civicrm.stackexchange.com/questions/7212/escaping-quotes-in-ckeditor-breaks-smarty-syntax/7213#7213
https://lab.civicrm.org/dev/core/-/issues/4149
Before
As per the description above.
After
These Smarty tokens are rendered correctly.
{contribution.receive_date|crmDate:"%E%f %B %Y"}
{contribution.receive_date|crmDate:'%E%f %B %Y'}
Technical Details
Comments
Also noting that the CKEditor configuration file is written to a "persistent" location: [civicrm.files]/persist/crm-ckeditor.js and really should be stored in a "dynamic" location: [civicrm.files]/persist/contribute/dyn/crm-ckeditor.js
Agileware Ref: CIVICRM-2103