From 81c3ee0e5f979c3e574e83fbcdb60d163c18792e Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 8 Aug 2013 23:23:19 +0200 Subject: [PATCH] Properly removing Emojis in messages --- .../install/files/lib/data/comment/CommentAction.class.php | 2 ++ .../files/lib/system/message/QuickReplyManager.class.php | 2 ++ wcfsetup/install/files/lib/util/MessageUtil.class.php | 3 +++ 3 files changed, 7 insertions(+) diff --git a/wcfsetup/install/files/lib/data/comment/CommentAction.class.php b/wcfsetup/install/files/lib/data/comment/CommentAction.class.php index 3bbd158dc0..ed308c50c7 100644 --- a/wcfsetup/install/files/lib/data/comment/CommentAction.class.php +++ b/wcfsetup/install/files/lib/data/comment/CommentAction.class.php @@ -17,6 +17,7 @@ use wcf\system\user\notification\object\CommentResponseUserNotificationObject; use wcf\system\user\notification\object\CommentUserNotificationObject; use wcf\system\user\notification\UserNotificationHandler; use wcf\system\WCF; +use wcf\util\MessageUtil; use wcf\util\StringUtil; /** @@ -501,6 +502,7 @@ class CommentAction extends AbstractDatabaseObjectAction { */ protected function validateMessage() { $this->readString('message', false, 'data'); + $this->parameters['data']['message'] = MessageUtil::stripCrap($this->parameters['data']['message']); if (empty($this->parameters['data']['message'])) { throw new UserInputException('message'); diff --git a/wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php b/wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php index 7e917d1bc1..ee9de085c8 100644 --- a/wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php +++ b/wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php @@ -11,6 +11,7 @@ use wcf\system\SingletonFactory; use wcf\system\WCF; use wcf\util\ArrayUtil; use wcf\util\ClassUtil; +use wcf\util\MessageUtil; /** * Manages quick replies and stored messages. @@ -163,6 +164,7 @@ class QuickReplyManager extends SingletonFactory { $parameters['data']['username'] = WCF::getUser()->username; // pre-parse message text + $parameters['data']['message'] = MessageUtil::stripCrap($parameters['data']['message']); $parameters['data']['message'] = PreParser::getInstance()->parse($parameters['data']['message'], $this->allowedBBodes); $message = $object->create(); diff --git a/wcfsetup/install/files/lib/util/MessageUtil.class.php b/wcfsetup/install/files/lib/util/MessageUtil.class.php index 2a8258b035..213560e0c1 100644 --- a/wcfsetup/install/files/lib/util/MessageUtil.class.php +++ b/wcfsetup/install/files/lib/util/MessageUtil.class.php @@ -32,6 +32,9 @@ class MessageUtil { // unify new lines $text = StringUtil::unifyNewlines($text); + // remove emoji (MySQL 5.1 does not support them) + $text = preg_replace('~\xF0\x9F[\x80-\xBF][\x80-\xBF]~', '', $text); + return $text; } -- 2.20.1