Conversation
Two amount-field rules in helpers/validation.ts accepted malformed input:
- isNumber used !isNaN(parseInt(v)); parseInt parses a leading numeric
prefix and ignores the rest, so "12abc" passed. Match the whole string
against an (optionally signed) integer/decimal number instead.
- validDecimal destructured only the second segment of v.split('.'), so a
value with two decimal points like "1.23.45" passed because its second
segment ("23") is two digits. Reject any value with more than one ".".
Both rules guard the amount fields on the debug paymentIntents and crypto
payment pages, where a downstream parseFloat would otherwise coerce the
malformed value to a different number. Add helpers/validation.test.ts (the
module's first unit test) covering both, and allow Jest to transform the
ESM-only uuid dependency the module imports so the test can load it.
devorun
force-pushed
the
fix/valid-decimal-multiple-dots
branch
from
August 14, 2026 20:54
454d75a to
3033730
Compare
Author
|
Friendly ping on this one — it's been open a few weeks with checks green. It tightens the shared |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two amount-field validation rules in
helpers/validation.tsaccept malformed input:isNumberused!isNaN(parseInt(v)).parseIntparses a leading numeric prefix and ignores the rest, soisNumber("12abc")returnstrue.validDecimaldestructured only the second segment ofv.split('.'), sovalidDecimal("1.23.45"),"1.55.99","100.00.00"all returntrue— the segment after the second.is silently ignored.Both rules guard the amount fields on
pages/debug/paymentIntents/create.vue,pages/debug/payments/crypto/create.vue, andpages/debug/payments/crypto/presign.vue. A field that passes these rules is later fed toparseFloat, which coerces the malformed value to a different number than the user typed.Fix
isNumber: match the whole string against an optionally-signed integer/decimal number (/^-?\d+(\.\d+)?$/) instead of relying onparseInt. Signed and decimal values keep working; trailing garbage, hex, and scientific-notation strings are rejected.validDecimal: reject any value with more than one.by checking the split length. Integer, exactly-two-decimals, and empty inputs are unchanged.Tests
Adds
helpers/validation.test.ts— the module's first unit test — with 11 cases across both rules (including the regressions above). Importing the module pulls in its ESM-onlyuuiddependency (used byisUUID), sojest.config.jsgets atransformIgnorePatternsentry allowing Jest to transformuuid.npx jestpasses (11/11);eslintis clean.Relationship to #467 / #468
Same class of bug as the
AmountInputgap in #467 (PR #468), but in a different, independent validator —helpers/validation.ts, used by the debug pages — that #468 does not touch.