gpt4 book ai didi

Htmlpurifier does not add some tags to the allowed ones(Htmlpurifier不会在允许的标签上添加一些标签)

转载 作者:bug小助手 更新时间:2023-10-28 13:23:22 29 4
gpt4 key购买 nike



I want to configure htmlpurifier so that it allows tags in html.
Htmlpurifier the whitelist with the tags table, tbody and does not work.
On the official website in demo mode, the table tag is also deleted even if you add it to the allowed ones. But the tag works correctly. Tell me, what am I doing wrong?

我想配置htmlPurier,这样它就可以在html中使用标签。HtmlPurier标签为TABLE、TBODY和的白名单不起作用。在Demo模式的官网上,即使添加到允许的表标签中,也会被删除。但标签工作正常。告诉我,我做错了什么?


You can try configure here: https://htmlpurifier.org/demo.php

您可以尝试在此处配置:https://htmlpurifier.org/demo.php


$whitelistTagList = ['u', 'table'];

$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.Allowed', implode(', ', $whitelistTagList));

return HTMLPurifier::getInstance()->purify($value, $config);

更多回答

Can you show us some HTML you're putting into this and what HTML Purifier is doing with it?

您能向我们展示一些您要放入其中的HTML语言吗?还有,HTMLPurier对它做了什么?

优秀答案推荐

It's worth noting that a <table> tag by itself isn't valid HTML. You also need to allow <tr>, <td>, <th>, et cetera. Otherwise HTML Purifier would, at best, turn input like this:

值得注意的是,

标记本身不是有效的HTML。您还需要允许
等。否则,在最好的情况下,HTMLPurator将像这样转换输入:


<table>
<tr>
<td>
Foo
</td>
</tr>
</table>

...into this through purification:

...通过净化变成这样:


<table>
Foo
</table>

...and since <table> requires other HMTL nodes inside it to be valid, the entire <table> tag and its contents will be removed.

由于

要求其内部的其他HMTL节点有效,因此将删除整个
标记及其内容。


As a sidenote, you should probably implode(',', $whitelistTagList), without the space. By coincidence it works with the space as well, but the described syntax of HTML.Allowed doesn't use spaces after commas:

作为附注,您可能应该内爆(‘,’,$White elistTagList),没有空格。巧合的是,它也适用于空格,但所描述的HTML语法。Allowed不在逗号后面使用空格:



Specify elements and attributes that are allowed using: element1[attr1|attr2],element2.... For example, if you would like to only allow paragraphs and links, specify a[href],p.



更多回答

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com