Browse Source

fix #817 修正评论和留言特殊符号转义、fix #841 配置保存

magicblack 3 years ago
parent
commit
d845303514

+ 1 - 1
application/admin/controller/System.php

@@ -92,7 +92,7 @@ class System extends Base
 
             $config['app']['search_vod_rule'] = join('|', $config['app']['search_vod_rule']);
             $config['app']['search_art_rule'] = join('|', $config['app']['search_art_rule']);
-            $config['app']['vod_search_optimise'] = join('|', $config['app']['vod_search_optimise']);
+            $config['app']['vod_search_optimise'] = join('|', !empty($config['app']['vod_search_optimise']) ? (array)$config['app']['vod_search_optimise'] : []);
 
             $config['extra'] = [];
             if(!empty($config['app']['extra_var'])){

+ 7 - 0
application/common.php

@@ -1208,6 +1208,13 @@ function mac_filter_xss($str)
     return htmlspecialchars(strip_tags(trim($str)), ENT_QUOTES);
 }
 
+function mac_restore_htmlfilter($str) {
+    if (stripos($str, '&') !== false) {
+        return htmlspecialchars_decode($str, ENT_QUOTES);
+    }
+    return $str;
+}
+
 function mac_format_text($str)
 {
     return str_replace(array('/',',','|','、',' ',',,,'),',',$str);

+ 2 - 0
application/common/model/Comment.php

@@ -41,6 +41,7 @@ class Comment extends Base {
         $user_ids=[];
         foreach($list as $k=>$v){
             $list[$k]['user_portrait'] = mac_get_user_portrait($v['user_id']);
+            $list[$k]['comment_content'] = mac_restore_htmlfilter($list[$k]['comment_content']);
 
             $where2=[];
             $where2['comment_pid'] = $v['comment_id'];
@@ -49,6 +50,7 @@ class Comment extends Base {
             $list[$k]['sub'] = $sub;
             foreach($sub as $k2=>$v2){
                 $list[$k]['sub'][$k2]['user_portrait'] = mac_get_user_portrait($v2['user_id']);
+                $list[$k]['sub'][$k2]['comment_content'] = mac_restore_htmlfilter($list[$k]['sub'][$k2]['comment_content']);
             }
             $list[$k]['data'] = [];
             if($v['comment_mid'] == 1){

+ 2 - 0
application/common/model/Gbook.php

@@ -31,6 +31,8 @@ class Gbook extends Base {
         $list = Db::name('Gbook')->where($where)->order($order)->limit($limit_str)->select();
         foreach ($list as $k=>$v){
             $list[$k]['user_portrait'] = mac_get_user_portrait($v['user_id']);
+            $list[$k]['gbook_content'] = mac_restore_htmlfilter($list[$k]['gbook_content']);
+            $list[$k]['gbook_reply'] = mac_restore_htmlfilter($list[$k]['gbook_reply']);
         }
         return ['code'=>1,'msg'=>lang('data_list'),'page'=>$page,'limit'=>$limit,'total'=>$total,'list'=>$list];
     }