Tyrrrz / DiscordChatExporter

Exports Discord chat logs to a file
MIT License
7.21k stars 657 forks source link

Twemoji URLs are incorrect for ZWJ sequences #834

Closed nightpool closed 2 years ago

nightpool commented 2 years ago

Version

master

Flavor

GUI (Graphical User Interface), CLI (Command Line Interface)

Export format

JSON

Details

When generating Twemoji URLs, Emoji.cs will skip all 0xfe0f sequences:

https://github.com/Tyrrrz/DiscordChatExporter/blob/36c9983c9ecc8609877f4afa3ed455b62ad6a0b0/DiscordChatExporter.Core/Discord/Data/Emoji.cs#L29-L32

However, this is incorrect based on Twemoji's URL generation code. See https://github.com/twitter/twemoji/issues/419. The logic for generating Twemoji URLs live here:

https://github.com/twitter/twemoji-parser/blob/f8312f35fdee0e79874bb50213c4544c14fa759b/src/index.js#L52-L56

Specifically, we should only remove 0xfe0f codepoints when the emoji sequence does not contain a zero width joiner (0x200d)

Steps to reproduce

The correct URL is https://twemoji.maxcdn.com/2/svg/1f575-fe0f-200d-2640-fe0f.svg

Tyrrrz commented 2 years ago

Thanks for the very descriptive bug report 🙏🏻 Happy to accept a PR on this