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

[4.x]: Restrict the usage of emoji #12935

Closed
Megafry opened this issue Mar 20, 2023 · 2 comments · Fixed by verbb/super-table#515 or spicywebau/craft-neo#731
Closed

[4.x]: Restrict the usage of emoji #12935

Megafry opened this issue Mar 20, 2023 · 2 comments · Fixed by verbb/super-table#515 or spicywebau/craft-neo#731
Assignees

Comments

@Megafry
Copy link

Megafry commented Mar 20, 2023

What happened?

Description

The feature #1627 that introduced emojis support can result in unintended consequences. For instance, I have an XML feed me import that contains a field with this specific notation for relations, ":100:41:62:", the field gets automatically transformed to "💯41:62:".

Steps to reproduce

  1. Add the following text to a text field: ":100: :1234:"
  2. Save the field.
  3. The text is now 💯 🔢

Expected behavior

it should be possible to specify whether emojis are allowed globally or at the field level.

Actual behavior

Emojis are allowed in all text fields and this can not be disabled:
:happy: => 😄

Craft CMS version

4.4.3

PHP version

8.0

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Feed Me - 5.1.0

@brandonkelly
Copy link
Member

brandonkelly commented Apr 3, 2023

Thanks for reporting this!

We discussed several possible fixes today, none of which were especially cut and dry. It’s not as simple as adding a field/general setting for disabling emoji shortcodes, for a couple reasons:

  1. Shortcodes are currently necessary for MySQL installs (until Craft 5 when we switch to utf8mb4 table charsets by default – see Bad default charset for `db/convert-charset` #11823), and we don’t want to make people have to choose between emoji support and avoiding this bug.
  2. There’s all the existing data to consider. If a setting disables shortcode conversion, suddenly a bunch of emoji would start to appear as shortcodes.

The solution we settled on ended up being a little complex, and is going to require updates to Neo and Super Table to be fully realized (spicywebau/craft-neo#731, verbb/super-table#515), so I’ve made the fix for Craft 4.5 rather than the next 4.4 release.

(We’ll also need to add a new “Escape shortcodes” setting for Plain Text fields to Feed Me, which will need to be enabled for any feeds that shouldn’t parse shortcodes – craftcms/feed-me#1270.)

In the meantime, you can work around this by creating a module (e.g. using Craft Generator), bootstrapped for every request, which configures LitEmoji to ignore the :100: and :1234: shortcodes:

\LitEmoji\LitEmoji::config('excludeShortcodes', [
    '100',
    '1234',
]);

@brandonkelly
Copy link
Member

Craft 4.5.0 is out with the fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants