Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Strip all variation selectors on emoji #3814

Merged
merged 3 commits into from
Jan 8, 2020
Merged

Conversation

dbkr
Copy link
Member

@dbkr dbkr commented Jan 7, 2020

...when inserting into or looking up in the unicode to emoji map.

This broke with emojibase 4.2.0 which changed the type of a whole
load of emojis to 'text' when previously they were 'emoji'. This
caused them to get the 'text' variant of the unicode string which
has the text variation selector (15) appended instead of the emoji
variation selector (16). We were only stripping the emoji selector,
so upgrading to 4.2.0 caused riot to fail to find the heart in the
unicode map, which therefore prevented the app from starting.

...when inserting into or looking up in the unicode to emoji map.

This broke with emojibase 4.2.0 which changed the type of a whole
load of emojis to 'text' when previously they were 'emoji'. This
caused them to get the 'text' variant of the unicode string which
has the text variation selector (15) appended instead of the emoji
variation selector (16). We were only stripping the emoji selector,
so upgrading to 4.2.0 caused riot to fail to find the heart in the
unicode map, which therefore prevented the app from starting.
src/emoji.js Outdated
ret += str.charAt(i);
}
}
return ret;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this not just be done using a regex unicode character range?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question: I'm not sure as I'd have to look at whether js regexes match by UTF-16 character code or by codepoint, which I suspect depends on whether you use an old style regex or an ES6 style 'u' regex?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nm: a regex is indeed fine. My code wasn't though because I had an 'and' when I needed an 'or'.

and my loop did not because I meant 'or', not 'and'
@dbkr dbkr requested a review from a team January 7, 2020 19:58
src/emoji.js Show resolved Hide resolved
@dbkr dbkr requested a review from t3chguy January 7, 2020 21:12
@dbkr dbkr merged commit 4e6bf30 into develop Jan 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants