CSharpSDK
CSharpSDK copied to clipboard
Fix for non-popular control characters not being escaped during JSON serialization
Refer to https://datatracker.ietf.org/doc/html/rfc4627.html#section-2.5.
-
Extend
EscapeCharactersto include the full\u0000to\u001frange. -
Add
BuildEscapeTableArray()and use it to populateEscapeTable. This has the added benefit of removing the explicit .cctor, which should simplify JIT code, since it shouldn't be implicitly inserting preamble cctor calls in all class methods (assuming my low level knowledge here circa 2017 still applies today). -
Modify
SerializeString()to handle control characters that require\uXXXX. -
Copypasta https://github.com/PlayFab/UnitySDK/blob/master/ExampleTestProject/Assets/Testing/Tests/Utility/JsonUnitTests.cs
-
Add new TestSimpleJsonSerializeStringWithEscapes to JsonUnitTests.cs for verifying non "popular control characters" are escaped via \uXXXX during SerializeString.
@toddbellMSFT, I leave this to you to test and land, since external PR's don't invoke automated tests. But the code itself looks good to me. 👍
This change was accepted into the codebase earlier this year: https://github.com/PlayFab/CSharpSDK/commit/0df95be0f09cd156223a2cb1ff96fe1ab87f3815