GSPには次のものがあります。
<%=model.something%>
そして Config.groovy には、次のものがあります。
grails {
views {
gsp {
encoding = 'UTF-8'
htmlcodec = 'xml' // use xml escaping instead of HTML4 escaping
codecs {
expression = 'html' // escapes values inside null
scriptlet = 'html' // escapes output from scriptlets in GSPs
taglib = 'html' // escapes output from taglibs
staticparts = 'none' // escapes output from static template parts
}
}
// escapes all not-encoded output at final stage of outputting
filteringCodecForContentType {
//'text/html' = 'html'
}
}
}
しかし、コントローラーで model.something = "<script>alert('something')</script>" を設定してビューをレンダリングすると、アラート ボックスが表示されます。
代わりに ${model.something} を使用するように変更すると、適切にエスケープするように見えます。しかし、念のため、スクリプトレットの出力もエンコードされるようにしたいと思います。それを行うには、構成に何か他のものが必要ですか?