emoji
emoji copied to clipboard
Fix edge cases in replace_emoji, demojize, and version functions
This PR fixes several edge cases and improves error handling in core emoji functions:
- Add bounds checking for alias processing in demojize() - Prevents IndexError when alias list is empty or aliases are too short
- Use safe key access for emoji version data in version() - Handles missing 'E' key gracefully with default value
- Prevent IndexError and KeyError on malformed emoji data - Makes functions more robust against corrupted data
Fixes:
emoji.replace_emoji("Hello 👋", replace="")now correctly returns "Hello "demojize()no longer crashes on empty/short aliasesversion()handles missing 'E' key gracefully
These changes improve the library's robustness when handling edge cases and malformed data.