commit da81c8eb5f516ad4df446a4c1feb21293545c8d1
parent ed4be602c487c423c8627676ab96fc5e16ac1925
Author: Marc Stibane <marc@taler.net>
Date: Tue, 21 Jul 2026 09:01:38 +0200
reject a trailing separator
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/taler-swift/Sources/taler-swift/Amount.swift b/taler-swift/Sources/taler-swift/Amount.swift
@@ -262,6 +262,9 @@ public final class Amount: Codable, Hashable, @unchecked Sendable, CustomStringC
if let dotIndex = amountStr.firstIndex(of: ".") {
let integerStr = String(amountStr[..<dotIndex])
let fractionStr = String(amountStr[string.index(dotIndex, offsetBy: 1)...])
+ if (fractionStr.isEmpty) { // reject a trailing separator, e.g. "EUR:1."
+ throw AmountError.invalidStringRepresentation
+ }
if (fractionStr.count > Self.fractionalBaseDigits) {
throw AmountError.invalidStringRepresentation
}