taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

refund-amount-swallows-extra-decimal-points.diff (1098B)


      1 diff --git a/taler-kotlin-android/src/main/java/net/taler/common/Amount.kt b/taler-kotlin-android/src/main/java/net/taler/common/Amount.kt
      2 index 34f534ca..c9d808c0 100644
      3 --- a/taler-kotlin-android/src/main/java/net/taler/common/Amount.kt
      4 +++ b/taler-kotlin-android/src/main/java/net/taler/common/Amount.kt
      5 @@ -96,6 +96,13 @@ data class Amount(
      6          fun fromString(currency: String, str: String): Amount {
      7              // value
      8              val valueSplit = str.split(".")
      9 +            // Everything after a second separator used to be dropped in
     10 +            // silence: "1.000.50" parsed as one unit and no fraction, so a
     11 +            // caller that trusted this with user input got an amount nobody
     12 +            // had typed.  isValidAmountStr has always rejected it; this makes
     13 +            // the parser agree with the validator.
     14 +            if (valueSplit.size > 2)
     15 +                throw AmountParserException("Malformed amount $str")
     16              val value = checkValue(valueSplit[0].toLongOrNull())
     17              // fraction
     18              val fraction: Int = if (valueSplit.size > 1) {