HTMLPurifier 破坏图像
我试图根据 WYSIWYG(CK 编辑器)的用户输入运行 HTMLPurifier,但图像损坏。
未过滤的输入:
<img alt="laugh" src="/lib/ckeditor/plugins/smiley/images/teeth_smile.gif" title="laugh">
使用默认设置运行净化器后:
<img alt=""laugh"" src="%5C" title=""laugh"">
我尝试更改配置设置;但我的 src 从未被保留。有什么想法吗?
I'm trying to run HTMLPurifier on user input from a WYSIWYG (CK Editor) and the images are breaking.
Unfiltered Input:
<img alt="laugh" src="/lib/ckeditor/plugins/smiley/images/teeth_smile.gif" title="laugh">
After running through purifier with default settings:
<img alt=""laugh"" src="%5C" title=""laugh"">
I have tried changing the configuration settings; but I the src is never preserved. Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我怀疑 magic_quotes 可能是一个原因..?
您还尝试过
$config->set('Core.RemoveInvalidImg',true);
吗?您使用哪个版本? (尝试旧的或新的)I have a suspicion that magic_quotes could be a reason..?
Also did you try
$config->set('Core.RemoveInvalidImg',true);
. Which version are you using? (Try older or newer)有同样的问题。
这解决了它
}
Had the same problem.
This fixed it
}
我不知道 htmlpurifier 是什么,但是在运行它之前,您拥有的 img 标签是完全合法的(除了它未关闭)。运行它后,它会双重转义,这看起来就像垃圾。 %5C 是反斜杠的 URL 代码。看起来它试图用反斜杠来逃避正斜杠,然后就窒息了。这个程序是什么?我可以推荐 HTML Tidy 吗?
I don't know what htmlpurifier is, but the img tag you have there is perfectly legitimate (except it is unclosed) before running it. After you run it, it is doubly escaping things and that just seems like garbage. %5C is the url code for a backslash. Seems like it is trying to escape the forward slash with a backslash and then it chokes. What is this program? Can I recommend HTML Tidy?
回到旧帖子,我认为这个小片段可能会帮助其他人最终到达这里。
我修复了代码中的大量与转义字符有关的异常活动,方法是将这一行添加到我的 .htaccess 文件中
来自 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
Coming back to an old post, I thought this little snippet might help others ending up here..
I fixed a multitude of unusual activity in my code to do with escaping characters by adding this line to my .htaccess file
From PHP documentation "This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0" http://www.php.net/manual/en/security.magicquotes.what.php
Also, here are other ways to disable magic quotes
http://www.php.net/manual/en/security.magicquotes.disabling.php