From 5736b7d978521ebc2010f295ee238f55b1d78356 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 4 Jan 2022 17:12:34 +0900 Subject: [PATCH] Fix cursors sent to osu-web being potentially string formatted in incorrect culture Fixed as per solution at https://github.com/JamesNK/Newtonsoft.Json/issues/874. Note that due to the use of `JsonExtensionDataAttribute` it's not feasible to change the actual specification to `JValue` in the `Dictionary`. In discussion with the osu-web team, it may be worthwhile to change the cursor to a string format where parsing is not required at our end. We could already do this in fact, but there are tests that rely on it being a `JToken` so the switch to `JValue` seems like the easier path right now. --- osu.Game/Extensions/WebRequestExtensions.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Extensions/WebRequestExtensions.cs b/osu.Game/Extensions/WebRequestExtensions.cs index b940c7498b..50837a648d 100644 --- a/osu.Game/Extensions/WebRequestExtensions.cs +++ b/osu.Game/Extensions/WebRequestExtensions.cs @@ -1,6 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Globalization; +using Newtonsoft.Json.Linq; using osu.Framework.IO.Network; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Online.API.Requests; @@ -16,7 +18,7 @@ namespace osu.Game.Extensions { cursor?.Properties.ForEach(x => { - webRequest.AddParameter("cursor[" + x.Key + "]", x.Value.ToString()); + webRequest.AddParameter("cursor[" + x.Key + "]", (x.Value as JValue)?.ToString(CultureInfo.InvariantCulture) ?? x.Value.ToString()); }); } }