Files
chatroom/app/Support/ChatContentSanitizer.php
T

24 lines
571 B
PHP

<?php
/**
* 文件功能:聊天室动态内容净化工具
*
* 统一处理用户输入在系统消息、公告与商城赠言中的 HTML 转义,避免动态文本注入到前端 innerHTML。
*/
namespace App\Support;
/**
* 类功能:提供聊天室系统文案中用户可控字段的安全转义能力。
*/
class ChatContentSanitizer
{
/**
* 将用户可控文本规整为可安全拼入受控 HTML 模板的字符串。
*/
public static function htmlText(?string $value): string
{
return e(trim((string) $value));
}
}