Skip to content

A local-first personal finance app

fix Tag filtering crashing app when tag has regex special character (#3725)

joel-richf265dd9df001
diff --git a/packages/loot-core/src/server/accounts/transaction-rules.ts b/packages/loot-core/src/server/accounts/transaction-rules.ts
index 5a98618618..3f952dcece 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 0000000000..7bbfceee53
--- /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