-
Notifications
You must be signed in to change notification settings - Fork 4k
Allow emojis with variant selectors to be validated #5583
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
Conversation
|
Hello @abhiklodh, thanks for your contribution I think we should not modify the emoji, and only "normalize" it for This comment could be helpful for you in case you want to work on this #5582 (comment) |
Hey @kajarenc! |
@abhiklodh could you please fix formatter error, and commit again to rerun CI: def is_emoji(text: str) -> bool:
"""Check if input string is a valid emoji."""
- return (text in ALL_EMOJIS) or ("\U0000FE0F" in text and text.replace("\U0000FE0F", "") in ALL_EMOJIS)
+ return (text in ALL_EMOJIS) or (
+ "\U0000FE0F" in text and text.replace("\U0000FE0F", "") in ALL_EMOJIS
+ ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @abhiklodh,
Sorry for the slow turnaround time on reviews for this PR!
This change LGTM, but I have one small change that I suggested along with a request that a couple unit tests get added to verify that these changes work as expected.
There are already some tests for this function that live here:
| @parameterized.expand( |
so adding another 2-3 cases to the parameterized list should be sufficient (copying some of the examples listed in the PR description should already be enough).
Once that's done, this PR should be good to go
|
Hey @vdonato And cleaned up this line too. https://github.com/abhiklodh/streamlit/blob/736b1093b5bf7f20c54a977d104c4a7c5ca28475/lib/streamlit/string_util.py#L44-L46 |
vdonato
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM
Thanks @abhiklodh!
# By Abhik Lodh (1) and others # Via GitHub * develop: memo_test/singleton_test: ensure ScriptRunCtx exists (streamlit#5739) Update loadApp command timeout (streamlit#5731) Allow emojis with variant selectors to be validated (streamlit#5583) # Conflicts: # lib/tests/streamlit/runtime/caching/cache_data_api_test.py # lib/tests/streamlit/runtime/caching/cache_resource_api_test.py
📚 Context
Emojis show up as invalid if they are prefixed or postfixed with a variant selector character. This is a hidden character that is used as variant selector for emojis (more information here).
What kind of change does this PR introduce?
🧠 Description of Changes
Wrote a function
clean_emojito remove hidden unicode and return a sanitised emoji if possible.Added logic to
validate_emojito handle emojis that have hidden unicode with the help ofclean_emoji.Revised:
Current:
🧪 Testing Done
🌐 References
Does this depend on other work, documents, or tickets?
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.