Skip to content

Commit

Permalink
uses CultureInfo.InvariantCulture to stringify claim values
Browse files Browse the repository at this point in the history
  • Loading branch information
gislikonrad authored and brentschmaltz committed Jun 26, 2020
1 parent 5560e2f commit 8433d58
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,13 @@ internal static object GetClaimValueUsingValueType(Claim claim)

if (claim.ValueType == ClaimValueTypes.Double)
{
if (double.TryParse(claim.Value, out double doubleValue))
if (double.TryParse(claim.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out double doubleValue))
return doubleValue;
}

if (claim.ValueType == ClaimValueTypes.Integer || claim.ValueType == ClaimValueTypes.Integer32)
{
if (int.TryParse(claim.Value, out int intValue))
if (int.TryParse(claim.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out int intValue))
return intValue;
}

Expand Down
6 changes: 3 additions & 3 deletions test/System.IdentityModel.Tokens.Jwt.Tests/JwtPayloadTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,16 @@ private static void SetDataSet(List<Claim> claims, TheoryData<List<Claim>, JwtPa
break;

case ClaimValueTypes.Double:
jsonValue = double.Parse(claim.Value);
jsonValue = double.Parse(claim.Value, CultureInfo.InvariantCulture);
break;

case ClaimValueTypes.Integer:
case ClaimValueTypes.Integer32:
jsonValue = int.Parse(claim.Value);
jsonValue = int.Parse(claim.Value, CultureInfo.InvariantCulture);
break;

case ClaimValueTypes.Integer64:
jsonValue = long.Parse(claim.Value);
jsonValue = long.Parse(claim.Value, CultureInfo.InvariantCulture);
break;

case ClaimValueTypes.DateTime:
Expand Down

0 comments on commit 8433d58

Please sign in to comment.