Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2022-05-17 00:41:49 +0300
committerGitHub <noreply@github.com>2022-05-17 00:41:49 +0300
commit8bb0e1e00c2ddc683168345d8aa88fc256481fc6 (patch)
tree459238d50089237b8ae6ad8865ac1c5434cda3d0
parentee89136c9af6b8812b9e206b7a455320ba1c89b2 (diff)
parent12849196ad70d431cc6636b858eedd641035822d (diff)
Merge pull request #32437 from nextcloud/bugfix/32256/backport/32220/stable24
Replace isValidEmoji by method in EmojiHelper
-rw-r--r--apps/user_status/lib/Service/EmojiService.php41
1 files changed, 3 insertions, 38 deletions
diff --git a/apps/user_status/lib/Service/EmojiService.php b/apps/user_status/lib/Service/EmojiService.php
index 0f197933872..9254c250b6b 100644
--- a/apps/user_status/lib/Service/EmojiService.php
+++ b/apps/user_status/lib/Service/EmojiService.php
@@ -26,6 +26,7 @@ declare(strict_types=1);
*/
namespace OCA\UserStatus\Service;
+use OC\Comments\EmojiHelper;
use OCP\IDBConnection;
/**
@@ -60,43 +61,7 @@ class EmojiService {
* @return bool
*/
public function isValidEmoji(string $emoji): bool {
- $intlBreakIterator = \IntlBreakIterator::createCharacterInstance();
- $intlBreakIterator->setText($emoji);
-
- $characterCount = 0;
- while ($intlBreakIterator->next() !== \IntlBreakIterator::DONE) {
- $characterCount++;
- }
-
- if ($characterCount !== 1) {
- return false;
- }
-
- $codePointIterator = \IntlBreakIterator::createCodePointInstance();
- $codePointIterator->setText($emoji);
-
- foreach ($codePointIterator->getPartsIterator() as $codePoint) {
- $codePointType = \IntlChar::charType($codePoint);
-
- // If the current code-point is an emoji or a modifier (like a skin-tone)
- // just continue and check the next character
- if ($codePointType === \IntlChar::CHAR_CATEGORY_MODIFIER_SYMBOL ||
- $codePointType === \IntlChar::CHAR_CATEGORY_MODIFIER_LETTER ||
- $codePointType === \IntlChar::CHAR_CATEGORY_OTHER_SYMBOL ||
- $codePointType === \IntlChar::CHAR_CATEGORY_GENERAL_OTHER_TYPES) {
- continue;
- }
-
- // If it's neither a modifier nor an emoji, we only allow
- // a zero-width-joiner or a variation selector 16
- $codePointValue = \IntlChar::ord($codePoint);
- if ($codePointValue === 8205 || $codePointValue === 65039) {
- continue;
- }
-
- return false;
- }
-
- return true;
+ $emojiHelper = new EmojiHelper($this->db);
+ return $emojiHelper->isValidEmoji($emoji);
}
}