简体   繁体   English

新Grails 2.3.7应用程序忽略了<%=%>

[英]New grails 2.3.7 app is ignoring <%= %>

I am writing a new grails 2.3.7 app and I'm trying to use <%= %> to avoid html encoding a domain class field. 我正在编写一个新的grails 2.3.7应用程序,并且试图使用<%=%>来避免html对域类字段进行编码。

For some reason grails is ignoring this and encoding the thing anyway. 由于某种原因,grails忽略了这一点,无论如何都对其进行编码。

As an example 举个例子

<%="<h2>FOO</h2>"%>

Just renders as 只是渲染为

<h2>FOO</h2>

and not as a level 2 header as expected. 而不是预期的2级标头。

This is not a bug but in fact Grails' automatic XSS attack prevention. 这不是错误,而是事实上Grails的自动XSS攻击防御功能。 See http://grails.org/doc/latest/guide/security.html#xssPrevention 请参阅http://grails.org/doc/latest/guide/security.html#xssPrevention

What you want to do it mark the output as raw: 您要执行的操作将输出标记为原始:

<%=raw("<h2>FOO</h2>")%>

However, note that this should be done with extreme care as you may put your application at risk of XSS attacks. 但是,请注意,应格外小心,因为您可能会使应用程序面临XSS攻击的风险。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Grails 2.3.7使用flash.message,i18n和html标记重定向控制器操作 - Grails 2.3.7 redirecting controller action with flash.message, i18n and html markup 为什么浏览器会忽略HTML文本区域内的新空行? - Why the browser is ignoring new empty lines inside the textarea in HTML? Chrome 扩展程序似乎忽略了 javascript 来启动新的 url - Chrome extension seems to be ignoring javascript to launch a new url 使用唯一的CSS /创建HTML页面,而忽略大多数通用应用程序CSS - make an html page with unique css/ ignoring most the universal app css 电子邮件编码:Gmail和Gmail应用似乎忽略了我的CSS - Email coding : Gmail and Gmail app seems to be ignoring my CSS 如何将gsp文件存储在grails-app / views / teamplates目录下并在Grails中修改它 - How to get the gsp file stored under grails-app/views/teamplates directory and modify it in Grails 如果用户在Android 2.3.7的文件输入中选择了文件,如何检入JS - How to check in JS if user selected a file in file input on Android 2.3.7 简单的问题 - 搜索中间的文本和忽略新行的标签 - Simple question - searching for text in between <td> and </td> tags ignoring new lines 新应用的随机图片脚本 - random picture script for new app 重新激活到新页面-Windows 8应用 - Reactivating to new page - Windows 8 app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM