From f584a26ae3155a60b4e0f21f35fb1bfe2f9c7484 Mon Sep 17 00:00:00 2001 From: JediKev <kevin@enhancesoft.com> Date: Wed, 19 Sep 2018 15:57:50 -0500 Subject: [PATCH] issue: Strip Emoticons This addresses an issue where emoticons/emojis cut off the remainder of the email when being added to a ticket thread. --- include/class.format.php | 28 ++++++++++++++++++++++++++++ include/class.thread.php | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/include/class.format.php b/include/class.format.php index fead2044d..61d28b66a 100644 --- a/include/class.format.php +++ b/include/class.format.php @@ -422,6 +422,34 @@ class Format { return strip_tags($decode?Format::htmldecode($var):$var); } + // Strip all Emoticon/Emoji characters until we support them + function strip_emoticons($text) { + return preg_replace(array( + '/[\x{1F601}-\x{1F64F}]/u', # Emoticons + '/[\x{1F680}-\x{1F6C0}]/u', # Transport/Map + '/[\x{1F600}-\x{1F636}]/u', # Add. Emoticons + '/[\x{1F681}-\x{1F6C5}]/u', # Add. Transport/Map + '/[\x{1F30D}-\x{1F567}]/u', # Other + '/[\x{1F910}-\x{1F999}]/u', # Hands + '/[\x{1F9D0}-\x{1F9DF}]/u', # Fantasy + '/[\x{1F9E0}-\x{1F9EF}]/u', # Clothes + '/[\x{1F6F0}-\x{1F6FF}]/u', # Misc. Transport + '/[\x{1F6E0}-\x{1F6EF}]/u', # Planes/Boats + '/[\x{1F6C0}-\x{1F6CF}]/u', # Bed/Bath + '/[\x{1F9C0}-\x{1F9C2}]/u', # Misc. Food + '/[\x{1F6D0}-\x{1F6D2}]/u', # Sign/P.O.W./Cart + '/[\x{1F500}-\x{1F5FF}]/u', # Uncategorized + '/[\x{1F300}-\x{1F3FF}]/u', # Cyclone/Amphora + '/[\x{24C2}-\x{1F251}]/u', # Enclosed + '/[\x{2702}-\x{27B0}]/u', # Dingbats + '/[\x{00A9}-\x{00AE}]/u', # Copyright/Registered + '/[\x{23F0}-\x{23FF}]/u', # Clock/Buttons + '/[\x{23E0}-\x{23EF}]/u', # More Buttons + '/[\x{2310}-\x{231F}]/u', # Hourglass/Watch + '/[\x{2322}-\x{232F}]/u' # Keyboard + ), '', $text); + } + //make urls clickable. Mainly for display function clickableurls($text, $target='_blank') { global $ost; diff --git a/include/class.thread.php b/include/class.thread.php index d6f21619a..bd47a8378 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -1306,7 +1306,7 @@ implements TemplateVariable { $vars['body'] = new TextThreadEntryBody($vars['body']); } - if (!($body = $vars['body']->getClean())) + if (!($body = Format::strip_emoticons($vars['body']->getClean()))) $body = '-'; //Special tag used to signify empty message as stored. $poster = $vars['poster']; -- GitLab