标签:xss removeXss thinkphp3.2 HTMLPurifier set clean font config
下载 HTMLPurifier github地址:https://github.com/ezyang/htmlpurifier 并与public同层级
function removeXSS($data)
{
require_once './HtmlPurifier/HTMLPurifier.auto.php';
// require_once '../../../HTMLpurifier/HTMLPurifier.auto.php';
$_clean_xss_config = \HTMLPurifier_Config::createDefault();
$_clean_xss_config->set('Core.Encoding', 'UTF-8');
// 设置保留的标签
$_clean_xss_config->set('HTML.Allowed', 'div,b,strong,i,em,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src]');
$_clean_xss_config->set('CSS.AllowedProperties', 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align');
$_clean_xss_config->set('HTML.TargetBlank', TRUE);
$_clean_xss_obj = new \HTMLPurifier($_clean_xss_config);
// 执行过滤
return $_clean_xss_obj->purify($data);
}
标签:xss,removeXss,thinkphp3.2,HTMLPurifier,set,clean,font,config 来源: https://www.cnblogs.com/w-m-y/p/15878497.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。
