diff --git a/plugins/Common.php b/plugins/Common.php index b75fb30..77416c7 100644 --- a/plugins/Common.php +++ b/plugins/Common.php @@ -3,6 +3,19 @@ * 常用的公用方法 */ Class Common { + public static function cleanSpecialChars($str) { + $findChars = array( + '"', + "'", + '&', + '<', + '>', + '\/', + ); + + return str_replace($findChars, '', $str); + } + public static function isCellphoneNumber($number) { return preg_match("/^1[3456789][0-9]{9}$/", $number); } diff --git a/themes/tajian/controller/FrontapiController.php b/themes/tajian/controller/FrontapiController.php index 5081973..db3abf6 100644 --- a/themes/tajian/controller/FrontapiController.php +++ b/themes/tajian/controller/FrontapiController.php @@ -690,7 +690,11 @@ eof; if (empty($nickname)) { $err = "请填写注册你的昵称"; - }else if (mb_strlen($nickname, 'utf-8') < 2 || mb_strlen($nickname, 'utf-8') > 5) { + }else { + $nickname = Common::cleanSpecialChars($nickname); + } + + if (mb_strlen($nickname, 'utf-8') < 2 || mb_strlen($nickname, 'utf-8') > 5) { $err = "昵称至少 2 个汉字,最多 5 个汉字,请按规则填写"; } diff --git a/themes/tajian/views/layout/main.php b/themes/tajian/views/layout/main.php index a74e0ad..f27f654 100644 --- a/themes/tajian/views/layout/main.php +++ b/themes/tajian/views/layout/main.php @@ -24,7 +24,7 @@ if (!empty(FSC::$app['config']['multipleUserUriParse']) && !empty(FSC::$app['use Ta荐 - - + -