Properly removing Emojis in messages
authorAlexander Ebert <ebert@woltlab.com>
Thu, 8 Aug 2013 21:23:19 +0000 (23:23 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 8 Aug 2013 21:23:19 +0000 (23:23 +0200)
wcfsetup/install/files/lib/data/comment/CommentAction.class.php
wcfsetup/install/files/lib/system/message/QuickReplyManager.class.php
wcfsetup/install/files/lib/util/MessageUtil.class.php

index 3bbd158dc02791f17f0aacec9220c716f4e8b7b3..ed308c50c7a7e0fdbfe3953dc16b04b3e48bbfc0 100644 (file)
@@ -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');
index 7e917d1bc1bd02f3fcb52f82bed400fd7f6565a3..ee9de085c86ff97cd37b140065568d8c3335e4ed 100644 (file)
@@ -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();
index 2a8258b0359bc2bc0f5153f38788460c903a6032..213560e0c151032b9458cd37b4cdba7299662746 100644 (file)
@@ -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;
        }