Skip to content

Commit 990c64e

Browse files
authored
fix(template): do not escape html character with double curly brackets (renovatebot#42136)
1 parent 18c118c commit 990c64e

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/util/template/index.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,23 @@ describe('util/template/index', () => {
171171
});
172172
});
173173

174+
it.each`
175+
input | expected
176+
${'foo'} | ${'foo'}
177+
${'>='} | ${'>='}
178+
${'<~'} | ${'<~'}
179+
${'<= {{ newVersion }}'} | ${'<= 1.6.0'}
180+
${'<= {{{ newVersion }}}'} | ${'<= 1.6.0'}
181+
${'& {{ newValue}}'} | ${'& >= 1.6.0'}
182+
`(
183+
'do not escape common range symbols: $input -> $output',
184+
({ input, expected }) => {
185+
expect(
186+
template.compile(input, { newVersion: '1.6.0', newValue: '>= 1.6.0' }),
187+
).toBe(expected);
188+
},
189+
);
190+
174191
it('lowercase', () => {
175192
const userTemplate = "{{{ lowercase 'FOO'}}}";
176193
const output = template.compile(userTemplate, {});

lib/util/template/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ export function compile<T>(
317317
: data;
318318

319319
logger.trace({ template, filteredInput }, 'Compiling template');
320-
const result = handlebars.compile(template)(filteredInput);
320+
const result = handlebars.compile(template, { noEscape: true })(
321+
filteredInput,
322+
);
321323

322324
if (warnVariables.size > 0) {
323325
logger.info(

0 commit comments

Comments
 (0)