阻止 symfony 从查询结果中转义 html

发布于 2024-09-16 10:04:46 字数 1536 浏览 1 评论 0原文

目前我在 Symfony 中使用 ckEditor 和 ckFinder。当我保存表单时,HTML 会(看起来如此)正确保存在数据库中。当我通过 symfony 查询并检索结果时,html 标签将被删除并替换。我可以阻止这种情况吗?以下是数据库中内容的示例。我尝试输入 HTML 显示的内容,但当前的 eidtor 对其进行了翻译

数据库显示:

<p> Test</p> <p> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="quality" value="high" /><param name="movie" value="/uploads/flash/test1.flv" /><embed pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" src="/uploads/flash/test1.flv" type="application/x-shockwave-flash"></embed></object></p>

Actaul HTML(注意,我将所有 ; 替换为 __,因为编辑器将其翻译为上述内容):

&lt__p&gt__ 测试__ &lt__p>__ <__object classid="__clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"__ codebase="__http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6, 0,40,0&quot__&gt__&lt__param name=&quot__quality&quot__ value=&quot__high&quot__ /&gt__&lt__param name=&quot__movie&quot__ value=&quot__/uploads/flash/test1. flv&quot__ /&gt__&lt__embed pluginspage=&quot__http://www.macromedia.com/go/getflashplayer&quot__ 质量=&quot__high&quot__ src=&quot__/uploads/flash/test1.flv&quot__ type=&quot__application/x-shockwave-flash&quot__&gt__&lt__/embed&gt__&lt__/object&gt__&lt__/p&gt__

Currently I am using ckEditor with ckFinder in Symfony. When I save a form the HTML is saved (seemingly so) properly in the database. When I query through symfony and retrieve the results, the html tags are removed and replaced. Can I prevent this? Below is an example of what is in the database. I tried putting in what the HTML Shows but the current eidtor translates it

Database shows:

<p> Test</p> <p> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="quality" value="high" /><param name="movie" value="/uploads/flash/test1.flv" /><embed pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" src="/uploads/flash/test1.flv" type="application/x-shockwave-flash"></embed></object></p>

Actaul HTML (Note I replaced all ; with __ as the editor was translating it to the the above otherwise):

<__p>__
Test<__/p>__
<__p>__
<__object classid="__clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"__ codebase="__http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"__>__<__param name="__quality"__ value="__high"__ />__<__param name="__movie"__ value="__/uploads/flash/test1.flv"__ />__<__embed pluginspage="__http://www.macromedia.com/go/getflashplayer"__ quality="__high"__ src="__/uploads/flash/test1.flv"__ type="__application/x-shockwave-flash"__>__<__/embed>__<__/object>__<__/p>__

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尘曦 2024-09-23 10:04:46

我猜你必须打开自动输出转义并在模板中回显查询结果。阅读此处什么是自动的输出转义以及使用 ESC_RAW 常量或 getRaw() 方法如何为您提供帮助。

you must have automatic output escaping turned on and echo the result of your query in a templates I guess. Read here what automatic output escaping is and how the use of the ESC_RAW constant or of the getRaw() method can help you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文