Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Incorrect Emoji Rendering #15830

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rahulrana701
Copy link

FIxes Issue Number #15824

Fix Description:
Prevented unintended emoji conversion for 💯 and other emojis in IPv6 addresses by introducing backticks.
Ensured proper rendering of classic smileys like :P, :D, and :).
Refined regex handling to accurately distinguish between emoji codes and regular text.
Fixed edge cases where certain symbols incorrectly triggered emoji rendering.

@jitsi-jenkins
Copy link

Hi, thanks for your contribution!
If you haven't already done so, could you please make sure you sign our CLA (https://jitsi.org/icla for individuals and https://jitsi.org/ccla for corporations)? We would unfortunately be unable to merge your patch unless we have that piece :(.

@@ -199,6 +200,43 @@ class ChatInput extends Component<IProps, IState> {

}


_sanitizeMessage(text: string): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what approach you took here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what approach you took here?
I created the _sanitizeMessage function to properly handle IPv6 addresses, timestamps, and prevent unintended emoji conversion. However, the IPv6 address solution was affecting other emojis, preventing them from rendering correctly. To fix this, I introduced an emoji map to ensure every emoji is processed accurately. I placed _sanitizeMessage before trimming to ensure proper handling before sending the message.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what approach you took here?
I created the _sanitizeMessage function to properly handle IPv6 addresses, timestamps, and prevent unintended emoji conversion. However, the IPv6 address solution was affecting other emojis, preventing them from rendering correctly. To fix this, I introduced an emoji map to ensure every emoji is processed accurately. I placed _sanitizeMessage before trimming to ensure proper handling before sending the message.

The _sanitizeMessage function processes the input message to ensure correct formatting before sending. It first wraps IPv6 addresses and timestamps in backticks to prevent unintended emoji conversion. Then, it converts valid emoji codes like ❤️ and classic smileys like :P or :D into their respective emojis. Finally, it prevents accidental emoji conversions in regular text by ensuring : is not mistakenly treated as an emoji trigger.

The function returns a cleaned-up message string where all intended emojis render correctly while preserving special cases like IP addresses and timestamps.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that is a good solution, there could be arbitrary text that it's not IP addresses. Not to mention the performance impact of applying so many regexes to every message.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that is a good solution, there could be arbitrary text that it's not IP addresses. Not to mention the performance impact of applying so many regexes to every message.

Sure, let me see if I can think of a better way or improve this one.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @saghul, instead of using regex to handle the emoji rendering issue, we can take a different approach by modifying the output of the toArray function directly within the Message component. This allows us to control how text and emojis are processed at the rendering stage, ensuring that only valid emoji patterns are transformed while preserving other text elements like IPv6 addresses. This approach improves efficiency and maintains message integrity without relying on multiple regex checks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's your take on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants