From da8b9b5e303a60d552e6ddb65ecdffc404a7c001 Mon Sep 17 00:00:00 2001 From: augushong Date: Thu, 21 Jul 2022 09:41:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9PHP8.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Request.php | 2 +- app/common.php | 27 ++++++++++++++++++++++++++- config/view.php | 2 ++ runtime/.gitignore | 2 -- 4 files changed, 29 insertions(+), 4 deletions(-) delete mode 100644 runtime/.gitignore diff --git a/app/Request.php b/app/Request.php index bf830dc..6978a8e 100644 --- a/app/Request.php +++ b/app/Request.php @@ -13,5 +13,5 @@ namespace app; class Request extends \think\Request { - + protected $filter = ['ua_htmlspecialchars']; } diff --git a/app/common.php b/app/common.php index d4edac6..b7a2978 100644 --- a/app/common.php +++ b/app/common.php @@ -129,7 +129,7 @@ function save_url_file($url, $type) $model_file->save_name = $save_name; $model_file->save(); - + unlink($temp_file); return $save_name; } @@ -276,3 +276,28 @@ function app_url(string $url = '', array $vars = [], $suffix = true, $domain = f return url($url, $vars, $suffix, $domain); } + + +if (!function_exists('ua_htmlspecialchars')) { + function ua_htmlspecialchars($string) + { + + if (is_null($string)) { + $string = ''; + } + + return htmlspecialchars($string); + } +} + +if (!function_exists('ua_htmlentities')) { + function ua_htmlentities($string) + { + + if (is_null($string)) { + $string = ''; + } + + return htmlentities($string); + } +} \ No newline at end of file diff --git a/config/view.php b/config/view.php index 01259a0..cb8e257 100644 --- a/config/view.php +++ b/config/view.php @@ -22,4 +22,6 @@ return [ 'taglib_begin' => '{', // 标签库标签结束标记 'taglib_end' => '}', + + 'default_filter' => 'ua_htmlentities', // 默认过滤方法 用于普通标签输出 ]; diff --git a/runtime/.gitignore b/runtime/.gitignore deleted file mode 100644 index c96a04f..0000000 --- a/runtime/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file