When a template function creates a template itself, make the new template inherit the escape setting from the parent. Signed-off-by: Gergely Nagy <algernon@balabit.hu> --- lib/templates.c | 1 + tests/unit/test_template.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/templates.c b/lib/templates.c index 6b23959..e084c1a 100644 --- a/lib/templates.c +++ b/lib/templates.c @@ -697,6 +697,7 @@ tf_simple_func_prepare(LogTemplateFunction *self, gpointer s, LogTemplate *paren for (i = 0; i < argc - 1; i++) { state->argv[i] = log_template_new(parent->cfg, NULL); + log_template_set_escape(state->argv[i], parent->escape); if (!log_template_compile(state->argv[i], argv[i + 1], error)) goto error; } diff --git a/tests/unit/test_template.c b/tests/unit/test_template.c index 8546dd4..723f479 100644 --- a/tests/unit/test_template.c +++ b/tests/unit/test_template.c @@ -253,6 +253,10 @@ test_escaping(void) { assert_template_format_with_escaping("${APP.QVALUE}", FALSE, "\"value\""); assert_template_format_with_escaping("${APP.QVALUE}", TRUE, "\\\"value\\\""); + assert_template_format_with_escaping("$(if (\"${APP.VALUE}\" == \"value\") \"${APP.QVALUE}\" \"${APP.QVALUE}\")", + FALSE, "\"value\""); + assert_template_format_with_escaping("$(if (\"${APP.VALUE}\" == \"value\") \"${APP.QVALUE}\" \"${APP.QVALUE}\")", + TRUE, "\\\"value\\\""); } int -- 1.7.10.4