[PR #5894] [CLOSED] [WIP] Fix: Support dollar sign ($) in hashtags for transaction filtering #24802

Closed
opened 2026-04-16 18:14:23 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/5894
Author: @Golenspade
Created: 10/9/2025
Status: Closed

Base: masterHead: fix/tags-dollar-sign-filter


📝 Commits (2)

  • 4552b41 Fix: Support dollar sign ($) in hashtags for transaction filtering
  • 4e04f79 chore(aql): format compiler.ts with Prettier to satisfy lint

📊 Changes

3 files changed (+124 additions, -8 deletions)

View changed files

📝 packages/loot-core/src/server/aql/compiler.ts (+16 -2)
📝 packages/loot-core/src/server/transactions/transaction-rules.test.ts (+101 -0)
📝 packages/loot-core/src/server/transactions/transaction-rules.ts (+7 -6)

📄 Description

Summary

Fixes #5680

This PR fixes a bug where tags containing dollar signs (e.g., #sal$ary, #cash$back) could not be filtered using the "Has tag(s)" filter in transactions.

Changes

Bug Fixes

  • Fixed regex pattern in hasTags case to correctly capture tags without the # prefix
  • Fixed tag comparison logic (t === tag instead of t.tag === tag)
  • Changed from using regex.source to string concatenation to preserve backslash escaping
  • Updated AQL compiler's $regexp case to re-escape $ characters that are lost during object serialization, while preserving regex anchor $ patterns

Testing

  • Added comprehensive unit tests for hasTags functionality covering:
    • Simple tags without special characters
    • Tags with underscores
    • Tags with dollar signs (the main bug fix)

Technical Details

The root cause was that backslashes in escaped dollar signs (\$) were lost during object serialization when passing regex patterns through the AQL query object.

When a tag like #sal$ary is processed:

  1. It gets escaped to sal\$ary in transaction-rules.ts
  2. The pattern becomes (?<!#)#sal\$ary([\s#]|$)
  3. During serialization, the backslash is lost, becoming (?<!#)#sal$ary([\s#]|$)
  4. This causes $ to be interpreted as a regex special character (end-of-string anchor) instead of a literal $

The fix re-escapes $ characters in the AQL compiler using a smart regex that only escapes $ not followed by ), which preserves genuine regex anchors like ([\s#]|$) while fixing literal dollar signs in tag content.

Test Results

All tests pass, including the new tests for dollar sign handling:

✓ transactions can be queried by hasTags

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/actualbudget/actual/pull/5894 **Author:** [@Golenspade](https://github.com/Golenspade) **Created:** 10/9/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `fix/tags-dollar-sign-filter` --- ### 📝 Commits (2) - [`4552b41`](https://github.com/actualbudget/actual/commit/4552b416c5a1d4d7f227963351b123e699cb8fa0) Fix: Support dollar sign ($) in hashtags for transaction filtering - [`4e04f79`](https://github.com/actualbudget/actual/commit/4e04f798b6a42267ba1721a0061a8f12eb181239) chore(aql): format compiler.ts with Prettier to satisfy lint ### 📊 Changes **3 files changed** (+124 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `packages/loot-core/src/server/aql/compiler.ts` (+16 -2) 📝 `packages/loot-core/src/server/transactions/transaction-rules.test.ts` (+101 -0) 📝 `packages/loot-core/src/server/transactions/transaction-rules.ts` (+7 -6) </details> ### 📄 Description ## Summary Fixes #5680 This PR fixes a bug where tags containing dollar signs (e.g., `#sal$ary`, `#cash$back`) could not be filtered using the "Has tag(s)" filter in transactions. ## Changes ### Bug Fixes - Fixed regex pattern in `hasTags` case to correctly capture tags without the `#` prefix - Fixed tag comparison logic (`t === tag` instead of `t.tag === tag`) - Changed from using `regex.source` to string concatenation to preserve backslash escaping - Updated AQL compiler's `$regexp` case to re-escape `$` characters that are lost during object serialization, while preserving regex anchor `$` patterns ### Testing - Added comprehensive unit tests for `hasTags` functionality covering: - Simple tags without special characters - Tags with underscores - Tags with dollar signs (the main bug fix) ## Technical Details The root cause was that backslashes in escaped dollar signs (`\$`) were lost during object serialization when passing regex patterns through the AQL query object. When a tag like `#sal$ary` is processed: 1. It gets escaped to `sal\$ary` in `transaction-rules.ts` 2. The pattern becomes `(?<!#)#sal\$ary([\s#]|$)` 3. During serialization, the backslash is lost, becoming `(?<!#)#sal$ary([\s#]|$)` 4. This causes `$` to be interpreted as a regex special character (end-of-string anchor) instead of a literal `$` The fix re-escapes `$` characters in the AQL compiler using a smart regex that only escapes `$` not followed by `)`, which preserves genuine regex anchors like `([\s#]|$)` while fixing literal dollar signs in tag content. ## Test Results All tests pass, including the new tests for dollar sign handling: ``` ✓ transactions can be queried by hasTags ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-16 18:14:23 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#24802