Procházet zdrojové kódy

过滤富文本字数限制

wzq před 5 roky
rodič
revize
2c4482ba2e
1 změnil soubory, kde provedl 8 přidání a 6 odebrání
  1. 8 6
      app/Repositories/Post/PostRepository.php

+ 8 - 6
app/Repositories/Post/PostRepository.php

@@ -87,12 +87,14 @@ class PostRepository
         $topicIds = implode(',', $topicIdsArray);
 
         //验证内容字数
-        $html = strip_tags($request['content']);
-        if (mb_strlen($html, 'UTF8') > 1000) {
-            return Response::create([
-                'message' => '所传内容不能超过1000字',
-                'status_code' => 500
-            ]);
+        if($request['type'] != 'html'){
+            $html = strip_tags($request['content']);
+            if (mb_strlen($html, 'UTF8') > 1000) {
+                return Response::create([
+                    'message' => '所传内容不能超过1000字',
+                    'status_code' => 500
+                ]);
+            }
         }
 
         $data = [