Skip to content
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

🩹 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

Merged
merged 1 commit into from
Mar 8, 2023

Conversation

agileware-justin
Copy link
Contributor

@agileware-justin agileware-justin commented Feb 28, 2023

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

@civibot
Copy link

civibot bot commented Feb 28, 2023

(Standard links)

@civibot civibot bot added the master label Feb 28, 2023
@agileware-justin agileware-justin changed the title Change CKEditor 4 default to not encode HTML entities by default which breaks Smarty syntax and prevents use of crmDate function dev/core/-/issues/4149 Change CKEditor 4 default to not encode HTML entities by default which breaks Smarty syntax and prevents use of crmDate function Feb 28, 2023
@demeritcowboy demeritcowboy added the merge ready PR will be merged after a few days if there are no objections label Mar 2, 2023
@demeritcowboy
Copy link
Contributor

I think this makes sense. I was a little worried about how it might affect activities but it still encodes < and >. The docs aren't too clear but I think it still encodes these nbsp,gt,lt,amp which is good.

@demeritcowboy demeritcowboy changed the title dev/core/-/issues/4149 Change CKEditor 4 default to not encode HTML entities by default which breaks Smarty syntax and prevents use of crmDate function dev/core#4149 Change CKEditor 4 default to not encode HTML entities by default which breaks Smarty syntax and prevents use of crmDate function Mar 8, 2023
@demeritcowboy demeritcowboy merged commit d4675b1 into civicrm:master Mar 8, 2023
@agileware-justin agileware-justin changed the title dev/core#4149 Change CKEditor 4 default to not encode HTML entities by default which breaks Smarty syntax and prevents use of crmDate function 🩹 dev/core#4149 Change CKEditor 4 default to not encode HTML entities by default which breaks Smarty syntax and prevents use of crmDate function Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
master merge ready PR will be merged after a few days if there are no objections
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants