From f265dd9df001af0bf6a4b8f3acd39ca3844266de Mon Sep 17 00:00:00 2001 From: joel-rich <6070705+joel-rich@users.noreply.github.com> Date: Sun, 27 Oct 2024 02:10:52 -0600 Subject: [PATCH] fix Tag filtering crashing app when tag has regex special character (#3725) * fix Tag filtering crashing app when tag has regex special character * release-notes --------- Co-authored-by: Joel Rich --- packages/loot-core/src/server/accounts/transaction-rules.ts | 4 +++- upcoming-release-notes/3725.md | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 upcoming-release-notes/3725.md diff --git a/packages/loot-core/src/server/accounts/transaction-rules.ts b/packages/loot-core/src/server/accounts/transaction-rules.ts index 5a986186189..3f952dcece3 100644 --- a/packages/loot-core/src/server/accounts/transaction-rules.ts +++ b/packages/loot-core/src/server/accounts/transaction-rules.ts @@ -468,7 +468,9 @@ export function conditionsToAQL(conditions, { recurDateBounds = 100 } = {}) { return { $and: tagValues.map(v => { - const regex = new RegExp(`(^|\\s)${v}(\\s|$)`); + const regex = new RegExp( + `(^|\\s)${v.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(\\s|$)`, + ); return apply(field, '$regexp', regex.source); }), }; diff --git a/upcoming-release-notes/3725.md b/upcoming-release-notes/3725.md new file mode 100644 index 00000000000..7bbfceee53c --- /dev/null +++ b/upcoming-release-notes/3725.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [joel-rich] +--- + +fix Tag filtering crashing app when tag has regex special character