【问题标题】:Iframe not stored in mysql correctly from ckeditoriframe 未从 ckeditor 正确存储在 mysql 中
【发布时间】:2012-12-19 21:20:14
【问题描述】:

我正在使用 ckeditor 将格式化的文本发布到 mysql 数据库中。当我发布它时,它会将 iframe 转换为编码的 html,就像使用 htmlspacialchars 一样,但保留其余的 html 代码。

我得到了什么:

<p>&lt;iframe frameborder=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;http://php.net/manual/en/function.mysql-real-escape-string.php&quot;&gt;&lt;/iframe&gt;</p>

<p>&nbsp;</p>

<ul>
 <li>hi lol</li>
 <li>wow</li>
 <li>yaya</li>
</ul>

vs 我想要的:

<p><iframe frameborder="0" scrolling="no" src="http://php.net/manual/en/function.mysql-real-escape-string.php"></iframe></p>

<p>&nbsp;</p>

<ul>
 <li>hi lol</li>
 <li>wow</li>
 <li>yaya</li>
</ul>

这会导致它显示为 html 代码,而不是在页面上呈现 iframe。

我知道问题不是 mysql,因为当我直接通过 phpmyadmin 存储它时,它可以让它在页面上正常显示,渲染 iframe。

在tinymce中也发生了同样的事情,所以它可能是服务器权限的事情,我不知道。

【问题讨论】:

    标签: php mysql iframe ckeditor htmlspecialchars


    【解决方案1】:

    编辑器正在防御Cross Site Scripting 攻击。稍微搜索一下就找到了add an iframe with ckeditor 的正确方法。

    【讨论】:

    • 非常感谢!!!!我还对此进行了更多研究,发现如果您使用的是 codeigniter,在 system\core\Security.php 的第 427 行,您可以在这种情况下删除“顽皮”的 html 标签(iframe)。
    • @MikeDemen 您关于 codeigniter 的提示本身应该是一个答案,因为它对我有用。
    猜你喜欢
    • 1970-01-01
    • 2017-06-23
    • 1970-01-01
    • 1970-01-01
    • 2019-04-29
    • 2019-10-09
    • 2011-06-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多