diff --git a/src/Microsoft.AspNetCore.HttpOverrides/Internal/IPEndPointParser.cs b/src/Microsoft.AspNetCore.HttpOverrides/Internal/IPEndPointParser.cs index a797584b94..a550ee70e4 100644 --- a/src/Microsoft.AspNetCore.HttpOverrides/Internal/IPEndPointParser.cs +++ b/src/Microsoft.AspNetCore.HttpOverrides/Internal/IPEndPointParser.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Globalization; using System.Net; namespace Microsoft.AspNetCore.HttpOverrides.Internal @@ -62,7 +63,7 @@ namespace Microsoft.AspNetCore.HttpOverrides.Internal if (portPart != null) { int port; - if (int.TryParse(portPart, out port)) + if (int.TryParse(portPart, NumberStyles.None, CultureInfo.InvariantCulture, out port)) { endpoint = new IPEndPoint(address, port); return true; diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ConditionPatternParser.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ConditionPatternParser.cs index 9523b897df..53d841b0c7 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ConditionPatternParser.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/ApacheModRewrite/ConditionPatternParser.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Globalization; namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { @@ -216,7 +217,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.ApacheModRewrite { // If the type is an integer, verify operand is actually an int int res; - if (!int.TryParse(results.Operand, out res)) + if (!int.TryParse(results.Operand, NumberStyles.None, CultureInfo.InvariantCulture, out res)) { return false; } diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/InputParser.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/InputParser.cs index 7dc3f8d638..53c63dfb6d 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/InputParser.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/InputParser.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using Microsoft.AspNetCore.Rewrite.Internal.PatternSegments; namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite @@ -181,7 +182,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite var res = context.Capture(); int index; - if (!int.TryParse(res, out index)) + if (!int.TryParse(res, NumberStyles.None, CultureInfo.InvariantCulture, out index)) { throw new FormatException(Resources.FormatError_InputParserInvalidInteger(res, context.Index)); } diff --git a/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/UrlRewriteFileParser.cs b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/UrlRewriteFileParser.cs index 2a5b0f24a9..6bb08f41f1 100644 --- a/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/UrlRewriteFileParser.cs +++ b/src/Microsoft.AspNetCore.Rewrite/Internal/IISUrlRewrite/UrlRewriteFileParser.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Xml.Linq; @@ -219,7 +220,7 @@ namespace Microsoft.AspNetCore.Rewrite.Internal.IISUrlRewrite break; case ActionType.CustomResponse: int statusCode; - if (!int.TryParse(urlAction.Attribute(RewriteTags.StatusCode)?.Value, out statusCode)) + if (!int.TryParse(urlAction.Attribute(RewriteTags.StatusCode)?.Value, NumberStyles.None, CultureInfo.InvariantCulture, out statusCode)) { throw new InvalidUrlRewriteFormatException(urlAction, "A valid status code is required"); }