From: Alexander Ebert Date: Thu, 8 Aug 2013 21:23:19 +0000 (+0200) Subject: Properly removing Emojis in messages X-Git-Tag: 2.0.0_Beta_7~42^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=81c3ee0e5f979c3e574e83fbcdb60d163c18792e;p=GitHub%2FWoltLab%2FWCF.git Properly removing Emojis in messages --- 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; }