diff options
author | M Somerville <dracos@users.noreply.github.com> | 2018-09-01 18:42:02 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2018-09-01 19:42:02 +0200 |
commit | a060beee726de5295e1f608231975a90b7709a0a (patch) | |
tree | 7937d0347c368e9074e4ff905f92a997860747ca | |
parent | 5c609c7419b27e6bf4cb62e083275bb3c65c0f27 (diff) |
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.
-rw-r--r-- | app/javascript/mastodon/features/emoji/__tests__/emoji-test.js | 5 | ||||
-rw-r--r-- | app/javascript/mastodon/features/emoji/emoji.js | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/app/javascript/mastodon/features/emoji/__tests__/emoji-test.js b/app/javascript/mastodon/features/emoji/__tests__/emoji-test.js index d91b48497..c8425c4c6 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('<span class="invisible">😄<br/>😴</span>😇')) .toEqual('<span class="invisible">😄<br/>😴</span><img draggable="false" class="emojione" alt="😇" title=":innocent:" src="/emoji/1f607.svg" />'); }); + + it('skips the textual presentation VS15 character', () => { + expect(emojify('✴︎')) // This is U+2734 EIGHT POINTED BLACK STAR then U+FE0E VARIATION SELECTOR-15 + .toEqual('<img draggable="false" class="emojione" alt="✴" title=":eight_pointed_black_star:" src="/emoji/2734.svg" />'); + }); }); }); diff --git a/app/javascript/mastodon/features/emoji/emoji.js b/app/javascript/mastodon/features/emoji/emoji.js index 0f005dd50..988cea253 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 = `<img draggable="false" class="emojione" alt="${match}" title="${title}" src="${assetHost}/emoji/${filename}.svg" />`; 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); |