Skip to content
Prev Previous commit
Next Next commit
Fixed 'h:mm:ss' being accepted by TimeSpanConverter.
  • Loading branch information
CodeBlanch committed Jun 28, 2021
commit 0248a1529654fe99bb029b2a77728a0dbf5f0c6a
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace System.Text.Json.Serialization.Converters
{
internal sealed class TimeSpanConverter : JsonConverter<TimeSpan>
{
private const int MinimumTimeSpanFormatLength = 7; // h:mm:ss
private const int MinimumTimeSpanFormatLength = 8; // hh:mm:ss
private const int MaximumTimeSpanFormatLength = 26; // -dddddddd.hh:mm:ss.fffffff
private const int MaximumEscapedTimeSpanFormatLength = JsonConstants.MaxExpansionFactorWhileEscaping * MaximumTimeSpanFormatLength;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ private static void DeserializeLongJsonString(int stringLength)
[InlineData("\\u0032\\u0033\\u003A\\u0035\\u0039\\u003A\\u0035\\u0039", "23:59:59")]
[InlineData("23:59:59.9", "23:59:59.9000000")]
[InlineData("23:59:59.9999999")]
[InlineData("1:00:00", "01:00:00")] // 'g' Format, allowed by Utf8Parser 'c' parser
[InlineData("9999999.23:59:59.9999999")]
[InlineData("-9999999.23:59:59.9999999")]
[InlineData("10675199.02:48:05.4775807")] // TimeSpan.MaxValue
Expand Down Expand Up @@ -491,7 +490,8 @@ public static void TimeSpan_Read_KnownDifferences()
[InlineData("00:00:60")]
[InlineData("00:00:00.00000009")]
[InlineData("900000000.00:00:00")]
[InlineData("1:2:00:00")] // 'g' Format, disallowed by Utf8Parser 'c' parser
[InlineData("1:00:00")] // 'g' Format
[InlineData("1:2:00:00")] // 'g' Format
[InlineData("+00:00:00")]
[InlineData("2021-06-18")]
[InlineData("1$")]
Expand Down