From 537c1bea2d320093fa88d8d966f8ddacd0e1234d Mon Sep 17 00:00:00 2001 From: liyuchun <563917701@qq.com> Date: Thu, 28 Apr 2022 02:06:10 +0000 Subject: [PATCH] * Fix bug #15039. --- lib/base/filter/filter.class.php | 19 ------------------- lib/filter/filter.class.php | 18 ++++++++++++++++++ module/bug/model.php | 8 ++++---- module/testcase/model.php | 4 ++-- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/lib/base/filter/filter.class.php b/lib/base/filter/filter.class.php index 020f440076..8db2523369 100644 --- a/lib/base/filter/filter.class.php +++ b/lib/base/filter/filter.class.php @@ -1370,23 +1370,4 @@ class baseFixer foreach($fields as $key => $fieldName) if(!isset($this->data->$fieldName)) unset($fields[$key]); return $fields; } - - /** - * 过滤Emoji表情。 - * Filter Emoji. - * - * @param string $fieldName - * @access public - * @return object - */ - public function filterEmoji($fieldName){ - $fields = $this->processFields($fieldName); - foreach($fields as $fieldName) - { - $this->data->$fieldName = preg_replace_callback('/./u', function (array $match){ - return strlen($match[0]) >= 4 ? '' : $match[0]; - }, $this->data->$fieldName); - } - return $this; - } } diff --git a/lib/filter/filter.class.php b/lib/filter/filter.class.php index 623386462c..f4e9980630 100644 --- a/lib/filter/filter.class.php +++ b/lib/filter/filter.class.php @@ -75,6 +75,7 @@ class fixer extends baseFixer } if(isset($flowFields[$field]) and ($flowFields[$field]->control == 'textarea' or $flowFields[$field]->control == 'richtext')) $this->skipSpecial($field); $this->specialChars($field); + $this->data->$field = $this->filterEmoji($value); } if(empty($fields)) return $this->data; @@ -90,4 +91,21 @@ class fixer extends baseFixer return $this->data; } + + /** + * 过滤Emoji表情。 + * Filter Emoji. + * + * @param string $value + * @access public + * @return object + */ + public function filterEmoji($value){ + $value = preg_replace_callback('/./u', function (array $match) + { + return strlen($match[0]) >= 4 ? '' : $match[0]; + }, $value); + + return $value; + } } diff --git a/module/bug/model.php b/module/bug/model.php index 268d4c6536..ed068e2f61 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1410,10 +1410,10 @@ class bugModel extends model /** * Get statistic. - * - * @param int $productID - * @param string $endDate - * @param int $days + * + * @param int $productID + * @param string $endDate + * @param int $days * @access public * @return void */ diff --git a/module/testcase/model.php b/module/testcase/model.php index 4bd0abe109..440db17d21 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -72,7 +72,7 @@ class testcaseModel extends model $parentStepID = 0; $this->loadModel('score')->create('testcase', 'create', $caseID); - $data = fixer::input('post')->filterEmoji('steps,expects')->get(); + $data = fixer::input('post')->get(); foreach($data->steps as $stepID => $stepDesc) { if(empty($stepDesc)) continue; @@ -759,7 +759,7 @@ class testcaseModel extends model /* Ignore steps when post has no steps. */ if($this->post->steps) { - $data = fixer::input('post')->filterEmoji('steps,expects')->get(); + $data = fixer::input('post')->get(); foreach($data->steps as $stepID => $stepDesc) {