Timespan in API should be parsed with invariant culture

This commit is contained in:
nicolas.dorier 2024-07-11 21:40:44 +09:00
parent daeeb58f71
commit 63a3667406
No known key found for this signature in database
GPG key ID: 6618763EF09186FE

View file

@ -1,4 +1,5 @@
using System; using System;
using System.Globalization;
using NBitcoin.JsonConverters; using NBitcoin.JsonConverters;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -58,7 +59,7 @@ namespace BTCPayServer.Client.JsonConverters
return null; return null;
return TimeSpan.Zero; return TimeSpan.Zero;
} }
if (reader.TokenType == JsonToken.String && TimeSpan.TryParse(reader.Value?.ToString(), out var res)) if (reader.TokenType == JsonToken.String && TimeSpan.TryParse(reader.Value?.ToString(), CultureInfo.InvariantCulture, out var res))
return res; return res;
if (reader.TokenType != JsonToken.Integer) if (reader.TokenType != JsonToken.Integer)
throw new JsonObjectException("Invalid timespan, expected integer", reader); throw new JsonObjectException("Invalid timespan, expected integer", reader);