From f21c1c58cefdbcd5c62c9f81cdfd30a5c9786871 Mon Sep 17 00:00:00 2001 From: M Somerville Date: Sat, 1 Sep 2018 18:42:02 +0100 Subject: [PATCH] Skip VS15 (Emoji textual presentation). (#8553) Mastodon converts all Emoji to images, whether they have a VS15 after them or not, but leaves the VS15 in the string, which is displayed as a black box in Safari. --- .../mastodon/features/emoji/__tests__/emoji-test.js | 5 +++++ app/javascript/mastodon/features/emoji/emoji.js | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/app/javascript/mastodon/features/emoji/__tests__/emoji-test.js b/app/javascript/mastodon/features/emoji/__tests__/emoji-test.js index d91b484975..c8425c4c6d 100644 --- a/app/javascript/mastodon/features/emoji/__tests__/emoji-test.js +++ b/app/javascript/mastodon/features/emoji/__tests__/emoji-test.js @@ -73,5 +73,10 @@ describe('emoji', () => { expect(emojify('😇')) .toEqual('😇'); }); + + it('skips the textual presentation VS15 character', () => { + expect(emojify('✴︎')) // This is U+2734 EIGHT POINTED BLACK STAR then U+FE0E VARIATION SELECTOR-15 + .toEqual('✴'); + }); }); }); diff --git a/app/javascript/mastodon/features/emoji/emoji.js b/app/javascript/mastodon/features/emoji/emoji.js index 0f005dd504..988cea2530 100644 --- a/app/javascript/mastodon/features/emoji/emoji.js +++ b/app/javascript/mastodon/features/emoji/emoji.js @@ -62,6 +62,10 @@ const emojify = (str, customEmojis = {}) => { const title = shortCode ? `:${shortCode}:` : ''; replacement = `${match}`; rend = i + match.length; + // If the matched character was followed by VS15 (for selecting text presentation), skip it. + if (str.codePointAt(rend) === 65038) { + rend += 1; + } } rtn += str.slice(0, i) + replacement; str = str.slice(rend);