我尝试使用HTMLPurifier从FCKEditor中过滤我的用户提交。我的意图是只允许一些HTML标记(如p、img、a等)具有自己的属性(如对齐或样式)。但结果是HTMLPurifier仍然剥离了属性。
Doctype: XHTML 1.0过渡编码: UTF-8
这是我的配置:
require PATH_SYSTEM . 'libs/htmlpurifier/HTMLPurifier.standalone.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.Allowed', 'p[align|style],strong,a[href|title|mailto],em,table[class|width|cellpadding],td,tr,h3,h4,h5,hr,br,u,ul,ol,li,img[src|width|height|alt|class],span[class],strike,sup,sub');
$purifier = new HTMLPurifier($config);下面是我的PHP代码:
foreach ($_POST as $post=>$value)
{
$_POST[$post] = $purifier->purify($value);
}我也尝试了HTML.AllowedElements和HTML.AllowedAttributes,但仍然产生与上面配置相同的结果。
谢谢。
发布于 2011-12-09 10:39:11
你记得关掉魔术引号了吗?演示程序似乎很好地处理了这些属性:http://bit.ly/uIleOd
https://stackoverflow.com/questions/8440262
复制相似问题