收口聊天室安全边界并优化特效生命周期

This commit is contained in:
2026-04-25 02:52:30 +08:00
parent 4d3f4f7a4b
commit 855d031b04
26 changed files with 1219 additions and 175 deletions
+23
View File
@@ -0,0 +1,23 @@
<?php
/**
* 文件功能:聊天室动态内容净化工具
*
* 统一处理用户输入在系统消息、公告与商城赠言中的 HTML 转义,避免动态文本注入到前端 innerHTML。
*/
namespace App\Support;
/**
* 类功能:提供聊天室系统文案中用户可控字段的安全转义能力。
*/
class ChatContentSanitizer
{
/**
* 将用户可控文本规整为可安全拼入受控 HTML 模板的字符串。
*/
public static function htmlText(?string $value): string
{
return e(trim((string) $value));
}
}