Merge pull request #3434 from thelounge/xpaw/no-variant-emoji-map

Remove \uFE0F emoji variant from emoji name map
This commit is contained in:
Pavel Djundik 2019-11-28 20:15:42 +02:00 committed by GitHub
commit 320b3ea98f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 351 additions and 331 deletions

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,7 @@ import LinkPreviewFileSize from "../../components/LinkPreviewFileSize.vue";
import InlineChannel from "../../components/InlineChannel.vue";
import Username from "../../components/Username.vue";
const emojiModifiersRegex = /[\u{1f3fb}-\u{1f3ff}]/gu;
const emojiModifiersRegex = /[\u{1f3fb}-\u{1f3ff}]|\u{fe0f}/gu;
// Create an HTML `span` with styling information for a given fragment
function createFragment(fragment, createElement) {

View File

@ -4,6 +4,9 @@ const got = require("got");
const path = require("path");
const fs = require("fs");
// same regex as found in client/../parse.js
const emojiModifiersRegex = /[\u{1f3fb}-\u{1f3ff}]|\u{fe0f}/gu;
(async () => {
const response = await got(
"https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json"
@ -13,7 +16,8 @@ const fs = require("fs");
const fullNameEmojiMap = {};
for (const emoji of emojiStrategy) {
fullNameEmojiMap[emoji.emoji] = emoji.description;
const cleanEmoji = emoji.emoji.replace(emojiModifiersRegex, "");
fullNameEmojiMap[cleanEmoji] = emoji.description;
for (const alias of emoji.aliases) {
emojiMap[alias] = emoji.emoji;

View File

@ -458,6 +458,22 @@ describe("IRC formatted message parser", () => {
expected:
'<span role="img" aria-label="Emoji: woman shrugging" title="Emoji: woman shrugging" class="emoji">🤷‍♀️</span>',
},
{
name: "with emoji variant selector",
input: "\u{2695}\u{FE0F}",
expected:
'<span role="img" aria-label="Emoji: medical symbol" title="Emoji: medical symbol" class="emoji">\u{2695}\u{FE0F}</span>',
},
{
name: "with text variant selector",
input: "\u{2695}\u{FE0E}",
expected: "\u{2695}\u{FE0E}", // this does not match because FE0E is specifically a text variant
},
{
name: "without variant selector",
input: "\u{2695}",
expected: "\u{2695}", // this does not match because emoji-regex expects \uFE0F as per the emoji specification
},
{
// FIXME: These multiple `span`s should be optimized into a single one. See https://github.com/thelounge/thelounge/issues/1783
name: "wrapped in style",