[PR #6247] fix: Handle unicode minus in number parsing #6409

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

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

State: closed
Merged: Yes


Fixes #6206.

When importing CSV files generated by Numbers on macOS, amounts may contain the Unicode minus sign (U+2212) instead of the ASCII hyphen-minus. This caused parsing to fail (resulting in positive numbers instead of negative).

This PR updates looselyParseAmount, currencyToAmount, and stringToInteger in loot-core/src/shared/util.ts to replace Unicode minus with ASCII minus before parsing.

Added unit tests to cover these cases.


Open in Cursor Open in Web


Note

Normalize U+2212 to '-' in parsing utilities and add tests to ensure negative values are handled correctly.

  • Core utilities:
    • Number parsing: currencyToAmount, stringToInteger, and looselyParseAmount now normalize Unicode minus (\u2212) to ASCII -; parentheses + Unicode minus handled correctly.
  • Tests:
    • Add unit tests covering Unicode minus across parsing scenarios.
  • Release notes:
    • Add upcoming-release-notes/6247.md entry documenting the bugfix.

Written by Cursor Bugbot for commit 2728303adf. This will update automatically on new commits. Configure here.

**Original Pull Request:** https://github.com/actualbudget/actual/pull/6247 **State:** closed **Merged:** Yes --- Fixes #6206. When importing CSV files generated by Numbers on macOS, amounts may contain the Unicode minus sign (U+2212) instead of the ASCII hyphen-minus. This caused parsing to fail (resulting in positive numbers instead of negative). This PR updates `looselyParseAmount`, `currencyToAmount`, and `stringToInteger` in `loot-core/src/shared/util.ts` to replace Unicode minus with ASCII minus before parsing. Added unit tests to cover these cases. --- <a href="https://cursor.com/background-agent?bcId=bc-9db3987c-5c4f-4548-b865-18ab0b320957"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-cursor-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in Cursor" src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a href="https://cursor.com/agents?id=bc-9db3987c-5c4f-4548-b865-18ab0b320957"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-web-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web" src="https://cursor.com/open-in-web.svg"></picture></a> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Normalize U+2212 to '-' in parsing utilities and add tests to ensure negative values are handled correctly. > > - **Core utilities**: > - **Number parsing**: `currencyToAmount`, `stringToInteger`, and `looselyParseAmount` now normalize Unicode minus (`\u2212`) to ASCII `-`; parentheses + Unicode minus handled correctly. > - **Tests**: > - Add unit tests covering Unicode minus across parsing scenarios. > - **Release notes**: > - Add `upcoming-release-notes/6247.md` entry documenting the bugfix. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 2728303adf73159488eb984d2f94a849874c9b60. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
GiteaMirror added the pull-request label 2026-02-28 21:27:54 -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#6409