From c96df4f9b01d36bc9e728a40229c7921ba149564 Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Tue, 16 Jan 2024 15:37:14 -0500 Subject: [PATCH] fix(utils/yaml): Remove jinja2 block delimiters from YAML (#26682) --- lib/util/yaml.spec.ts | 7 +++++++ lib/util/yaml.ts | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/util/yaml.spec.ts b/lib/util/yaml.spec.ts index b09331b7d3474b9..68b339937c09a59 100644 --- a/lib/util/yaml.spec.ts +++ b/lib/util/yaml.spec.ts @@ -102,12 +102,19 @@ describe('util/yaml', () => { codeBlock` myObject: aString: {{value}} + {% if test.enabled %} + myNestedObject: + aNestedString: {{value}} + {% endif %} `, { removeTemplates: true }, ), ).toEqual({ myObject: { aString: null, + myNestedObject: { + aNestedString: null, + }, }, }); }); diff --git a/lib/util/yaml.ts b/lib/util/yaml.ts index 8921803f2975ba7..b8c2847fdf72475 100644 --- a/lib/util/yaml.ts +++ b/lib/util/yaml.ts @@ -37,7 +37,9 @@ function massageContent(content: string, options?: YamlOptions): string { if (options?.removeTemplates) { return content .replace(regEx(/{{`.+?`}}/gs), '') - .replace(regEx(/{{.+?}}/g), ''); + .replace(regEx(/{{.+?}}/g), '') + .replace(regEx(/{%`.+?`%}/gs), '') + .replace(regEx(/{%.+?%}/g), ''); } return content;