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)
Sun, Nov 10, 1:59 PM
Unknown Object (File)
Fri, Nov 8, 10:12 AM
Unknown Object (File)
Thu, Nov 7, 10:59 AM
Unknown Object (File)
Thu, Nov 7, 10:59 AM
Unknown Object (File)
Thu, Nov 7, 10:59 AM
Unknown Object (File)
Tue, Nov 5, 9:14 AM
Unknown Object (File)
Mon, Nov 4, 10:53 AM
Unknown Object (File)
Thu, Oct 31, 3:57 PM
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
No Lint Coverage
Unit
No Test Coverage

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

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.