Specify culture to int.TryParse #356
This commit is contained in:
parent
0fa31955a2
commit
c21cee940a
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue