我在codeigniter应用程序中使用htmlpurifier。当我直接使用html进行过滤时。例如:
$dirty_html = 'T<svg onload=alert(1);>est';
$clean_html = purify($dirty_html);
echo $clean_html;
当我简单地使用它时,我得到了过滤后的输出,但是当我与POST一起使用时,它没有过滤。请检查以下示例。
Output: test
当我使用帖子时,即$ this-> input-> post('name');根本不过滤。
$dirty_html = $this->input->post('name');
$clean_html = purify($dirty_html);
echo $clean_html;
Output: t<svg onload=alert(1);>est
使用post时获得上述输出。它没有过滤。
因为当您使用input-> post()时,它已经返回了由htmlspecialchars()过滤的值,因此将不应用净化器