阻止 symfony 从查询结果中转义 html [英] Stop symfony from escaping html from query result

查看:28
本文介绍了阻止 symfony 从查询结果中转义 html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

数据库显示:

<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(请注意,我将所有 ; 替换为 __,否则编辑器会将其翻译为上述内容):

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

&lt__p&gt__测试<__/p&gt__&lt__p&gt__&lt__object classid="__clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"__代码库="__http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0&quot__>__&lt__param name="__quality"__ value="__high&quot__/&gt__<__param name="__movie&quot__ value=&quot__/uploads/flash/test1.flv"__/>__&lt__embed pluginspage="__http://www.macromedia.com/go/getflashplayer"__ quality="__high&quot__ src=&quot__/uploads/flash/test1.flv"__type="__application/x-shockwave-flash&quot__>__<__/embed>__&lt__/object>__&lt__/p>__

&lt__p&gt__ Test&lt__/p&gt__ &lt__p&gt__ &lt__object classid=&quot__clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&quot__ codebase=&quot__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__ quality=&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__

推荐答案

你必须打开自动输出转义并在我猜的模板中回显你的查询结果.阅读这里什么自动输出转义是以及如何使用 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.

这篇关于阻止 symfony 从查询结果中转义 html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆