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

Closed
opened 2026-02-28 21:25:09 -06:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/actualbudget/actual/pull/5894

State: closed
Merged: No


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

**Original Pull Request:** https://github.com/actualbudget/actual/pull/5894 **State:** closed **Merged:** No --- ## 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)
GiteaMirror added the pull-request label 2026-02-28 21:25:09 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#6192