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

emoji favicons depend on python string length in a weird way #2888

Closed
tewhalen opened this issue Apr 13, 2024 · 1 comment
Closed

emoji favicons depend on python string length in a weird way #2888

tewhalen opened this issue Apr 13, 2024 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@tewhalen
Copy link

Description

Trying to use "⚔️" as a favicon for my app, and finding that it gives me the error "ValueError: invalid favicon: ⚔️", coming out of line 61 of favicon.py.

The issue here is that the crossed-swords emoji is made out of two unicode code points: \u2694 ("Crossed Swords") and \uFE0F ("Variation Selector-16" i.e. "display as emoji"). Python's len() gives 2 for this when it's a string, which means favicon.py's _is_char() returns false for this sort of emoji.

Solving this in a general way, i.e. "how can we determine whether a given string is actually a single emoji" seems way more difficult than this problem deserves, so my suggestion would simply be to rewrite the test in _is_char() to something like
return len(favicon) == 1 or "\ufe0f" in favicon - this feels like it'll catch a bunch more cases.

@falkoschindler
Copy link
Contributor

Thanks for reporting this issue, @tewhalen!

Solving this in a general way, i.e. "how can we determine whether a given string is actually a single emoji" seems way more difficult than this problem deserves

I totally agree. Adding "\ufe0f" in favicon would be a good quick fix - until someone wants to use something like 👍🏻 as a favicon. But I guess a general solution would require something like emoji. We can think about using it in the future.

Would you like to create a pull request handling \ufe0f? 🙂

@falkoschindler falkoschindler added the bug Something isn't working label Apr 13, 2024
@falkoschindler falkoschindler modified the milestones: 1.4.22, 1.4.23 Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants