我有以下字符串:
<p>
This is a test
</p>
<p>
More test text.
</p>
<p>
<a href="http://www.google.com/">google</a>
</p>
当我使用此代码通过HTMLPurifier运行时:
require_once(__DIR__ . '/../libraries/htmlpurifier-4.6.0-lite/library/HTMLPurifier.auto.php');
$config = \HTMLPurifier_Config::createDefault();
$config->set('HTML.Allowed', 'code,span,div,label,a,br,p,b,i,del,strike,u,img,video,audio,blockquote,mark,cite,small,ul,ol,li,hr,dl,dt,dd,sup,sub,big,pre,code,figure,figcaption,strong,em,table,tr,td,th,tbody,thead,tfoot,h1,h2,h3,h4,h5,h6');
$purifier = new \HTMLPurifier($config);
$sanitized = !empty($_POST['text'])?$purifier->purify($_POST['text']):null;
我收到错误:
允许的内存大小为134217728字节耗尽(尝试分配51746711字节)
为什么会这样?
编辑:
将配置行更改为:
$config->set('HTML.Allowed', 'code,span,div,label');
导致此错误:
允许的内存大小为134217728字节耗尽(尝试分配37415543字节)