From: Alexander Ebert Date: Fri, 19 Aug 2016 09:34:12 +0000 (+0200) Subject: Improved pattern for smiley code matches X-Git-Tag: 3.0.0_Beta_1~670 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c3ca3ee6fa78df99864673b45d2743e74bee8b92;p=GitHub%2FWoltLab%2FWCF.git Improved pattern for smiley code matches --- diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeTextParser.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeTextParser.class.php index d7d2b0372f..c8f8593969 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeTextParser.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeTextParser.class.php @@ -415,17 +415,24 @@ class HtmlInputNodeTextParser { protected function parseSmiley(\DOMText $text, $value) { static $smileyPattern = null; if ($smileyPattern === null) { + $difficultCodes = []; foreach ($this->smilies as $smileyCode => $url) { $smileyCode = preg_quote($smileyCode, '~'); if (!preg_match('~^\\\:.+\\\:$~', $smileyCode)) { - $smileyCode = '\B' . $smileyCode . '\B'; + $difficultCodes[] = $smileyCode; + continue; } if (!empty($smileyPattern)) $smileyPattern .= '|'; $smileyPattern .= $smileyCode; } + if (!empty($difficultCodes)) { + if (!empty($smileyPattern)) $smileyPattern .= '|'; + $smileyPattern .= '(?<=\s|^)(?:' . implode('|', $difficultCodes) . ')(?=\s|$)'; + } + $smileyPattern = '~(' . $smileyPattern . ')~'; }