HomePhabricator
Diffusion Comm 746427b642ba

[lib] Make sure all default emojis pass onlyOneEmojiRegex

Description

[lib] Make sure all default emojis pass onlyOneEmojiRegex

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

Reviewers: ginsu, atul

Reviewed By: atul

Subscribers: tomek, ginsu

Differential Revision: https://phab.comm.dev/D8145

Details

Provenance
ashoatAuthored on Jun 7 2023, 10:43 AM
Reviewer
atul
Differential Revision
D8145: [lib] Make sure all default emojis pass onlyOneEmojiRegex
Parents
rCOMM8d9e6fd35d0c: [lib] Stop setting dataLoaded from register / siweAuth actions
Branches
Unknown
Tags
Unknown