去评论
dz插件网

解决AI小编文库详情页显示HTML源码问题详细步骤(1)

小墨超可爱
2026/05/02 08:33:25
解决文库详情页显示HTML源码问题详细步骤问题现象
在AI文库详情页(plugin.php?id=aieditor_7ree:library_7ree&option=1&tid=xxx)中,论坛手动发布的帖子内容显示为HTML源代码(如 <p>...),而不是正常渲染的格式化文本。
原因分析解决步骤第1步:定位文件
修改文件:source/plugin/aieditor_7ree/include/library_7ree/page_7ree.php
第2步:添加循环解码与反转义函数
在文件末尾 ?> 之前添加以下清理危险CSS样式的函数(用于登录状态内容):
php



function cleanDangerousCSS_7ree($content) {    // 移除所有内联样式(包括HTML实体编码的样式)    $content = preg_replace('/\s*style\s*=\s*"[^"]*"/i', '', $content);    $content = preg_replace('/\s*style\s*=\s*&quot;[^&]*&quot;/i', '', $content);    $content = preg_replace('/\s*style\s*=\s*&#039;[^&]*&#039;/i', '', $content);        // 移除可能导致布局错乱的CSS属性    $content = preg_replace('/position\s*:\s*[^;"]+[;"]/i', '', $content);    $content = preg_replace('/display\s*:\s*flex[^;"]*[;"]/i', '', $content);    $content = preg_replace('/width\s*:\s*\d+px[;"]/i', '', $content);    $content = preg_replace('/margin-left\s*:\s*-\d+px[;"]/i', '', $content);    $content = preg_replace('/margin-right\s*:\s*-\d+px[;"]/i', '', $content);    $content = preg_replace('/margin-top\s*:\s*-\d+px[;"]/i', '', $content);    $content = preg_replace('/margin-bottom\s*:\s*-\d+px[;"]/i', '', $content);    $content = preg_replace('/z-index\s*:\s*\d+[;"]/i', '', $content);    $content = preg_replace('/float\s*:\s*[^;"]+[;"]/i', '', $content);    $content = preg_replace('/<svg[^>]*>.*?<\/svg>/is', '', $content);    $content = preg_replace('/<section[^>]*>\s*<\/section>/is', '', $content);    $content = preg_replace('/<span[^>]*>\s*<\/span>/is', '', $content);    return $content;}