Skip to content

Commit

Permalink
fix: escaping in action rule templating (#3632)
Browse files Browse the repository at this point in the history
* fix: escaping in action rule templating

* chore: release note
  • Loading branch information
UnderKoen authored Oct 11, 2024
1 parent 37ad584 commit 05dda5f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/loot-core/src/server/accounts/rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,16 @@ describe('Action', () => {
expect(item.notes).toBe('Hey Sarah! You just payed 10');
});

test('should not escape text', () => {
const action = new Action('set', 'notes', '', {
template: '{{notes}}',
});
const note = 'Sarah !@#$%^&*()<> Special';
const item = { notes: note };
action.exec(item);
expect(item.notes).toBe(note);
});

describe('regex helper', () => {
function testHelper(template: string, expected: unknown) {
test(template, () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/loot-core/src/server/accounts/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,9 @@ export class Action {
this.field = field;
this.type = typeName;
if (options?.template) {
this.handlebarsTemplate = Handlebars.compile(options.template);
this.handlebarsTemplate = Handlebars.compile(options.template, {
noEscape: true,
});
try {
this.handlebarsTemplate({});
} catch (e) {
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3632.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [UnderKoen]
---

Fix escaping in action rules templating

0 comments on commit 05dda5f

Please sign in to comment.