mirror of
https://github.com/friendica/friendica
synced 2025-04-30 15:04:23 +02:00
Add unit tests for Smilies::isEmojiPost
- Current implementation is failing tests with emojis including the zero-width-joiner character, encoded on 3 bytes only.
This commit is contained in:
parent
6ed440718d
commit
059a111282
2 changed files with 73 additions and 1 deletions
|
@ -289,11 +289,12 @@ class Smilies
|
|||
/**
|
||||
* Checks if the body only contains 4 byte unicode characters.
|
||||
*
|
||||
* @param string $body
|
||||
* @param string $body Possibly-HTML post body
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isEmojiPost(string $body): bool
|
||||
{
|
||||
// Strips all whitespace
|
||||
$conv = preg_replace('#\s#u', '', html_entity_decode($body));
|
||||
// Emojis are always 4 byte Unicode characters
|
||||
return (!empty($conv) && (strlen($conv) / mb_strlen($conv) == 4));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue