0

我在我的cakephp v1.3应用程序中使用了 wmd-editor 。

我写的配置如下:


wmd_options = {
            output: "HTML",

            lineLength: 40,

            buttons: "bold italic | link blockquote code image | ol ul heading hr",

            autostart: true
        };

当我提交表单时,启用 wmd 的 textarea 中的 HTML 保存在数据库中,并对文本进行了处理,然后使用方法自动htmlentities()对其进行解码。 但文本显示为包括这样的 HTML 编码html_entity_decode()

<p><strong>hello dear friends</strong></p>\n\n<pre><code>I want to make sure that everything that you type is visible clearly.\nadasfafas\n</code></pre>\n\n<blockquote>\n <p>sadgsagasdgxcbxcbxc</p>\n</blockquote>\n\n<p><em>sadfgsgasdsgasgs</em></p>\n\n<p><b><a href="http://kumu.in">this is the link</a></b></p>

请帮我解决这个问题

谢谢

4

2 回答 2

1

对于 XSS 的清理,通常最好将原始 HTML 保存在数据库中而不进行修改,并在输出/显示时清理。使用清理核心库。

于 2010-05-25T15:45:12.793 回答
0

由于您已将选项设置output: "HTML",为保存为 html,但是您可以使用该strip_tags功能从文本中删除 html 标签。

于 2010-05-25T10:00:00.610 回答