Skip to content

A local-first personal finance app

fix parsing schedule templates with brackets in the name (#5189)

Matt Farrelld821f1cebc2c
diff --git a/packages/loot-core/src/server/budget/goal-template.pegjs b/packages/loot-core/src/server/budget/goal-template.pegjs
index bb4ba87e03..41019ee380 100644
--- a/packages/loot-core/src/server/budget/goal-template.pegjs
+++ b/packages/loot-core/src/server/budget/goal-template.pegjs
@@ -87,16 +87,16 @@ day 'day' = $(d d)
date = $(month '-' day)
currencySymbol 'currency symbol' = symbol: . & { return /\p{Sc}/u.test(symbol) }
-// Match schedule name including spaces up until we see a [, looking ahead to make sure it's followed by increase/decrease
+// Match schedule name including spaces and brackets, but stop before percentage modifiers
rawScheduleName = $(
(
- [^ \t\r\n\[] // First character can't be space or [
+ !('['('increase'i/'decrease'i)) // Don't start with [increase/decrease
+ [^ \t\r\n] // First character can't be whitespace
(
- [^\r\n\[] // Subsequent characters can include spaces but not [
- /
- (![^\r\n\[]* '['('increase'i/'decrease'i)) [ ] // Or spaces if not followed by [increase/decrease
+ !(_ '['('increase'i/'decrease'i)) // Don't match if followed by [increase/decrease modifier
+ [^\r\n] // Any character except newlines
)*
)
-) { return text() }
+) { return text().trim() }
name 'Name' = $([^\r\n\t]+) { return text() }
\ No newline at end of file
diff --git a/upcoming-release-notes/5189.md b/upcoming-release-notes/5189.md
new file mode 100644
index 0000000000..32d7c879d0
--- /dev/null
+++ b/upcoming-release-notes/5189.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [MattFaz]
+---
+
+Fix parsing of schedule names containing square brackets conflicting with increase/decrease modifiers