JohnXLivingston / peertube-plugin-livechat

GNU Affero General Public License v3.0
90 stars 26 forks source link

Emoji Name Overlap Results in Wrong Emoji Being Used #576

Open vencabot opened 3 weeks ago

vencabot commented 3 weeks ago

Describe the bug If you have an emoji named like "ThisEmoji" and another emoji named "ThisEmojiOverlaps," when you send a message including "ThisEmojiOverlaps," you don't actually get the second emoji; you get the first emoji followed by the word 'Overlaps'.

To Reproduce Steps to reproduce the behavior:

  1. Name an emoji such that its name starts with the same, whole text as a previous emoji's name but then continues uniquely.
  2. Try to send a message to the chat including the new emoji.
  3. Instead of seeing the new, longer emoji, you'll see the old, shorter emoji, followed by the rest of the new emoji's name.

Expected behavior Especially when I select an emoji from the emoji menu, I expect for that emoji to appear in my message: not a different emoji, just because their names have some overlap. I believe that, when two emojis have names that overlap, the longer emoji should be selected, because that's the one that the user wants. Basically, I believe that the search-and-replace algorithm would need to be updated to address this issue.

Additional context Requiring emoji names to start and end with ":", without allowing ":" anywhere in the emoji name itself, fixes this problem. As I understand it, this used to be the case, which is probably why this issue never came up before. However, I agree that emoji names shouldn't be subject to such restrictions; re-implementing this restriction would break my chat bridge's ability to cross-post emojis from Twitch to PeerTube, since Twitch (and probably some other platforms which might be bridged) don't use colons as emoji terminators.

I have Twitch emojis that are named "HandR" and "HandRShake", and so I copy-pasted those emojis and their names to peertube-livechat so that the bridge would allow users to use the same emoji in both chats. Because of the behavior described in this report, not only does the wrong emoji get used when bridging messages, but the wrong emoji is also used when PeerTube users select their emoji from the emoji menu.

I'm going to temporarily address this issue by renaming these name-overlap emojis on both Twitch and PeerTube.

As always, thank you for everything that you do, sir! My apologies for dumping another Issue on you. Also, if this is something that should be reported to converse.js, please let me know and I'll do so.

JohnXLivingston commented 3 weeks ago

Hello. Thanks for the report (and thanks a lot for making them so detailed :) ).

I already knew about this bug, and reported it here: https://github.com/conversejs/converse.js/issues/3502 I was not able to fix it myself, i do not understand all involved code part.