Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.4.4
-
None
-
None
Description
TemplateConfiguration.setAutoEscape(true) only affects values in models top level. Nested values will not be escaped.
Example:
import groovy.text.markup.MarkupTemplateEngine import groovy.text.markup.TemplateConfiguration def tplConf = new TemplateConfiguration() tplConf.autoEscape = true def engine = new MarkupTemplateEngine(tplConf) def template = engine.createTemplate (''' html { body { div(unsafeContents) div(nested.unsafe) } } ''') model = new HashMap<String,Object>(); model.put("unsafeContents", "I am an <html> hacker."); model.put("nested", [unsafe: "I am an <html> hacker."]); Writable output = template.make(model) assert '<html><body><div>I am an <html> hacker.</div><div>I am an <html> hacker.</div></body></html>' == output.toString()
div(nested.unsafe) is not escaped.