Fix locale to "en-US" when parsing numbers (#3143)

This commit is contained in:
Kaloyan Raev 2019-09-30 07:07:37 -06:00 committed by GitHub
parent f94bc8e465
commit bd8807e43f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
using Microsoft.Deployment.WindowsInstaller; using Microsoft.Deployment.WindowsInstaller;
using System; using System;
using System.Globalization;
using System.IO; using System.IO;
namespace Storj namespace Storj
@ -126,7 +127,7 @@ namespace Storj
return ActionResult.Success; return ActionResult.Success;
} }
if (!double.TryParse(storageStr, out double storage)) if (!double.TryParse(storageStr, NumberStyles.Number, CultureInfo.CreateSpecificCulture("en-US"), out double storage))
{ {
session["STORJ_STORAGE_VALID"] = string.Format("'{0}' is not a valid number.", storageStr); session["STORJ_STORAGE_VALID"] = string.Format("'{0}' is not a valid number.", storageStr);
return ActionResult.Success; return ActionResult.Success;
@ -165,7 +166,7 @@ namespace Storj
return ActionResult.Success; return ActionResult.Success;
} }
if (!double.TryParse(bandwidthStr, out double bandwidth)) if (!double.TryParse(bandwidthStr, NumberStyles.Number, CultureInfo.CreateSpecificCulture("en-US"), out double bandwidth))
{ {
session["STORJ_BANDWIDTH_VALID"] = string.Format("'{0}' is not a valid number.", bandwidthStr); session["STORJ_BANDWIDTH_VALID"] = string.Format("'{0}' is not a valid number.", bandwidthStr);
return ActionResult.Success; return ActionResult.Success;