Table of Contents
#165 — Money amount fields accept scientific-notation input such as `1e3` and interpret it as a number (`1e3` → `$1000.00`), so a stray (Resolved)
← Back to bug list · View issue #165 in MantisBT
Reported by: Nour aboulhosn on 2026-08-04T09:00:00+01:00
Assigned to: Claude
Resolved by: Claude on 2026-08-04T13:19:21+01:00
Severity: major
Priority: high
Reproducibility: have not tried
Category: General
Description: The amount and unit-price fields treat any string the underlying numeric check accepts as valid, and that check includes scientific notation: `1e3` is stored as `$1000.00` and `5e-2` as `$0.05`. A user who mistypes — for instance intending a plain `1` but fat-fingering an exponent — can silently create an amount orders of magnitude away from what they meant, with no confirmation. (This does not bypass the maximum-amount cap; values like `9e9` are still rejected by their numeric value.) This must be resolved by restricting money inputs to plain decimal notation — an optional sign, digits, an optional single decimal separator, and up to the currency's number of fractional digits — and rejecting exponent notation with a clear message. Correctly functioning, `1e3` should be refused as not a valid amount (or the field should strip/ignore non-decimal characters), so that only ordinary decimal amounts a user would actually type are ever accepted.
Steps to Reproduce: 1. Go to Add an expense and enter `1e3` as the amount. 2. Save and reopen the expense — the stored amount is `$1000.00`. 3. The scientific-notation string was accepted as a number rather than rejected.
Resolution: WHAT `1e3` was accepted and stored as $1,000.00; `5e-2` as $0.05.
WHERE - app/classes/Core/Validator.php — looksLikeAmount(), money() - lang/en.php + lang/ar.php — validation.money_format
WHY The check was is_numeric(), which is not “is this an amount”. It also accepts 0x1A, leading whitespace and INF. None of those is something a person types into a box labelled “How much?”.
FIX looksLikeAmount() accepts plain decimal notation only — optional sign, digits, one optional decimal point — and money() reports a refusal as “How much? has to be a plain amount, like 1234.50.” Extra decimals are deliberately still allowed through the shape check so that 0.001 is reported as “must be more than zero” (see #164) rather than “that isn't a number”, which would be false.
VERIFIED (real HTTP posts) — 1e3, 5e-2, 1E3, 1e+3, 0x1A, “1,000”, “$10” and “abc” are all refused; 10, 12.5, 12.50, .5 and 99999999.99 all still save.
Regression test: tests/Core/MoneyRuleTest.php, a data provider per form.
Activity / Notes
- 2026-08-04T13:19:20+01:00 - Claude: WHAT
`1e3` was accepted and stored as $1,000.00; `5e-2` as $0.05.
WHERE - app/classes/Core/Validator.php — looksLikeAmount(), money() - lang/en.php + lang/ar.php — validation.money_format
WHY The check was is_numeric(), which is not “is this an amount”. It also accepts 0x1A, leading whitespace and INF. None of those is something a person types into a box labelled “How much?”.
FIX looksLikeAmount() accepts plain decimal notation only — optional sign, digits, one optional decimal point — and money() reports a refusal as “How much? has to be a plain amount, like 1234.50.” Extra decimals are deliberately still allowed through the shape check so that 0.001 is reported as “must be more than zero” (see #164) rather than “that isn't a number”, which would be false.
VERIFIED (real HTTP posts) — 1e3, 5e-2, 1E3, 1e+3, 0x1A, “1,000”, “$10” and “abc” are all refused; 10, 12.5, 12.50, .5 and 99999999.99 all still save.
Regression test: tests/Core/MoneyRuleTest.php, a data provider per form.
Full History
| Date | User | Field | Change |
|---|---|---|---|
| 2026-08-04T09:00:00+01:00 | Nour aboulhosn | issue-new | New Issue |
| 2026-08-04T13:19:20+01:00 | Claude | note-added | Note Added: 0000123 |
| 2026-08-04T13:19:21+01:00 | Claude | tag-added | Tag Attached: done-by-claude |
| 2026-08-04T13:19:21+01:00 | Claude | Assigned To | ⇒ Claudine |
| 2026-08-04T13:19:21+01:00 | Claude | Status | new ⇒ resolved |
| 2026-08-04T13:19:21+01:00 | Claude | Resolution | open ⇒ fixed |
Synced automatically from MantisBT issue #165.
