-
Notifications
You must be signed in to change notification settings - Fork 641
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
Saving "special" emoji in text fields causes 'Control character error, possibly incorrectly encoded.' #2725
Comments
I’m not able to even save an entry with a 🦄 when using MySQL (get a SQL error), and not able to reproduce the the exception when using PostgreSQL. Have you made any changes to your environment to get past this error in MySQL?
|
I've managed to recreate this in two different environments: Nanobox (locally and on a staging site) and also in MAMP Pro 4.2. In both environments when saving the 🦄, it produced the malformed data in the |
We fixed this at the root, by adding a validation error for textual custom fields that contain emojis (or any other 4+ byte characters), if the DB doesn't support 4+ byte characters. (Any characters that are converted to HTML entities or emoji shortcodes by the field type before being saved won’t be affected.) |
Great, thanks! |
Hmm, I have jsut hit this issue with a customer adding some order notes (to some line item custom data) with an emoji in it. I am wondering what the best fix is in this case - db end (unicode mb4?) - js (strip emjois - but inevitably people will be putting them in and expect them to work I expect) - ... or somewhere else? @brandonkelly Any tips on this? |
@bossanova808 Can you repost on the Commerce repo? |
Issue here - craftcms/commerce#886 (comment) I commented on the fix too, because it's not complete for my use case yet: craftcms/commerce@11c5dc2 - but maybe it's too hard in that case? Not sure how universal you want to be with accepting this data... |
When saving "special" emoji within text fields (such as 🦄), causes this error:
This error is raised in
in /app/vendor/yiisoft/yii2/helpers/BaseJson.php
and/app/vendor/craftcms/cms/src/services/EntryRevisions.php
.At line
390
inEntryRevisions.php
:After further investigation looking in the database, this is an issue specifically with the
entryversions
table and what gets saved in thedata
column when a "special" emoji is used.You can see a comparison below, with the
data
column content showing an entry with normal text and an example when I saved the entry with a 🦄:Normal Data
When saved with 🦄
You can see above, that the data was not saved correctly when the special emoji is used. It cuts off at
{"181":"
and therefore causes a JSON decoding error.The text was updated successfully, but these errors were encountered: