return str_replace($matches[0], $t, $matches[0]);
}
+
+ /**
+ * Checks if the body only contains 4 byte unicode characters.
+ *
+ * @param string $body
+ * @return boolean
+ */
+ public static function isEmojiPost(string $body): bool
+ {
+ $conv = html_entity_decode(str_replace([' ', "\n", "\r"], '', $body));
+ // Emojis are always 4 byte Unicode characters
+ return (!empty($conv) && (strlen($conv) / mb_strlen($conv) == 4));
+ }
}
$text = preg_replace("/\[event\-id\](.*?)\[\/event\-id\]/ism", '', $text);
}
- if (!$for_plaintext && DI::config()->get('system', 'big_emojis') && ($simple_html != self::DIASPORA)) {
- $conv = html_entity_decode(str_replace([' ', "\n", "\r"], '', $text));
- // Emojis are always 4 byte Unicode characters
- if (!empty($conv) && (strlen($conv) / mb_strlen($conv) == 4)) {
- $text = '<span style="font-size: xx-large; line-height: normal;">' . $text . '</span>';
- }
+ if (!$for_plaintext && DI::config()->get('system', 'big_emojis') && ($simple_html != self::DIASPORA) && Smilies::isEmojiPost($text)) {
+ $text = '<span style="font-size: xx-large; line-height: normal;">' . $text . '</span>';
}
// Handle mentions and hashtag links
namespace Friendica\Protocol;
+use Friendica\Content\Smilies;
use Friendica\Content\Text\BBCode;
use Friendica\Core\Logger;
use Friendica\Core\Protocol;
*/
public static function isWantedLanguage(string $body)
{
+ if (empty($body) || Smilies::isEmojiPost($body)) {
+ Logger::debug('Empty body or only emojis', ['body' => $body]);
+ return true;
+ }
+
$languages = [];
foreach (Item::getLanguageArray($body, 10) as $language => $reliability) {
if ($reliability > 0) {