3

我正在尝试对来自所见即所得(CK 编辑器)的用户输入运行 HTMLPurifier,并且图像正在中断。

未过滤的输入:

<img alt="laugh" src="/lib/ckeditor/plugins/smiley/images/teeth_smile.gif" title="laugh">

使用默认设置运行净化器后:

<img alt="&quot;laugh&quot;" src="%5C" title="&quot;laugh&quot;">

我尝试更改配置设置;但我的 src 从未保存过。有什么想法吗?

4

4 回答 4

4

我怀疑magic_quotes 可能是一个原因..?

你也试过了$config->set('Core.RemoveInvalidImg',true);。您使用的是哪个版本?(尝试旧的或新的)

于 2010-10-09T05:54:24.647 回答
3

有同样的问题。这修复了它

if (get_magic_quotes_gpc()) {
function stripslashes_gpc(&$value)
{
    $value = stripslashes($value);
}
array_walk_recursive($_GET, 'stripslashes_gpc');
array_walk_recursive($_POST, 'stripslashes_gpc');
array_walk_recursive($_COOKIE, 'stripslashes_gpc');
array_walk_recursive($_REQUEST, 'stripslashes_gpc');

}

于 2011-01-13T21:33:39.860 回答
1

我不知道 htmlpurifier 是什么,但是你拥有的 img 标签在运行之前是完全合法的(除了它是未关闭的)。在你运行它之后,它会双重逃避东西,这看起来就像垃圾一样。%5C 是反斜杠的 url 代码。似乎它正试图用反斜杠来逃避正斜杠,然后它就窒息了。这个程序是什么?我可以推荐HTML Tidy吗?

于 2010-10-09T05:33:52.987 回答
1

回到旧帖子,我认为这个小片段可能会帮助其他人在这里结束..

通过将此行添加到我的 .htaccess 文件中,我修复了我的代码中与转义字符有关的大量异常活动

php_flag magic_quotes_gpc Off

来自 PHP 文档“此功能自 PHP 5.3.0 起已弃用,自 PHP 5.4.0 起已删除” http://www.php.net/manual/en/security.magicquotes.what.php

此外,这里还有其他禁用魔术引号的方法 http://www.php.net/manual/en/security.magicquotes.disabling.php

于 2012-07-23T15:16:33.350 回答