Page MenuHomePhabricator

[lib] Make sure all default emojis pass onlyOneEmojiRegex
ClosedPublic

Authored by ashoat on Jun 7 2023, 12:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 7, 4:05 PM
Unknown Object (File)
Thu, Mar 7, 4:05 PM
Unknown Object (File)
Thu, Mar 7, 7:45 AM
Unknown Object (File)
Thu, Mar 7, 1:44 AM
Unknown Object (File)
Mon, Mar 4, 11:31 PM
Unknown Object (File)
Feb 24 2024, 10:07 AM
Unknown Object (File)
Feb 24 2024, 10:07 AM
Unknown Object (File)
Feb 24 2024, 10:07 AM
Subscribers

Details

Summary

Turns out that macOS appends the U+FE0F the character to some Unicode emojis when you select them from the native OS emoji selector. It's not clear why Apple does this, or why it only happens for a certain set of emoji.

This still counts as valid emoji Unicode. However, our onlyOneEmojiRegex thinks it's two emojis.

Our implementation of onlyOneEmojiRegex involves introspecting into the RegExp string that emoji-regex uses, and is not an officially supported approach by that package. emoji-regex supports matching emojis in text, and checking if the text includes only emoji. But checking for precisely one emoji is more complicated, and our approach (which is basically just extracting the raw RegExp and putting it inside of /^()$/) doesn't work in some scenarios where U+FE0F is suffixed.

Luckily we don't use the native macOS emoji selector in any of our UIs, but it does look like @ginsu used it to select some of the emojis. The diff adds a unit test to make sure all of the default emojis pass onlyOneEmojiRegex, and fixes all failing emojis.

Test Plan

I noticed that a test username of at4 would match up with an anchor emoji as the default, and the anchor emoji was failing to be set. After this diff everything worked

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Had to change text encoding in Phabricator to "see the difference," but looks good.

ee6b93.png (718×2 px, 475 KB)

This revision is now accepted and ready to land.Jun 7 2023, 1:13 PM
lib/shared/emojis.test.js
27–32 ↗(On Diff #27533)

Might be good to add a failing case with a comment explaining the macOS issue (mostly just a link to this diff)?

This revision was landed with ongoing or failed builds.Jun 7 2023, 2:05 PM
This revision was automatically updated to reflect the committed changes.