Grails中元标记的属性被自动转义 [英] Attributes in meta tags in Grails being auto escaped

查看:91
本文介绍了Grails中元标记的属性被自动转义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了元属性在Grails中双重转义的问题,例如:

< meta name =titlecontent =$ {'bla bla bla'。encodeAsHTML()}/>

正在变为:

< meta name =title content =bla bla& amp; amp; amp; amp; amp; quot;>

显然,去除encodeAsHTML否则自动转义,而不是我确定自动转义的地方。

解决方案

事实证明 meta ,标题 body 标记的属性具有。 encodeAsHTML() SiteMeshTagLib.groovy 中调用它们。

这应该是真的记录在某处,因为我找不到任何提及它,并认为它可能是一个错误。


I was having a problem with meta attributes being double escaped in Grails, so for instance:
<meta name="title" content="${'bla bla "bla"'.encodeAsHTML()}" />
was becoming:
<meta name="title" content="bla bla &amp;quot;bla&amp;quot;">
Obviously removing encodeAsHTML() stops the double escape but it is strange as nothing else auto escaped, and not I'm sure where else things might be automatically escaped.

解决方案

It turns out meta, title and body tag's attributes have .encodeAsHTML() called on them within SiteMeshTagLib.groovy.

This should really be documented somewhere, because I couldn't find any mention of it and thought it might be a bug.

这篇关于Grails中元标记的属性被自动转义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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