aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE
diff options
context:
space:
mode:
authorjduncanator <1518948+jduncanator@users.noreply.github.com>2020-03-25 09:26:37 +1100
committerGitHub <noreply@github.com>2020-03-24 23:26:37 +0100
commitdaecb1193de369390ee0efd0a8dc4c21de2ed9ba (patch)
tree483b1d36de011a1763d587a98a415caf05c12dc6 /Ryujinx.HLE
parent17200214dfbd60ba075f106e558d4f563a1bbe98 (diff)
prepo: Resolve JSON parsing issues in prepo report handling (#1022)
It seems MsgPack.Cli incorrectly converts some unicode control characters directly to JSON literal Unicode strings (eg. '\1'). As these are invalid, pretty printing the JSON report fails. This removes pretty printing, pending a proper implementation, and tidies up MsgPack deserialization.
Diffstat (limited to 'Ryujinx.HLE')
-rw-r--r--Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs31
1 files changed, 9 insertions, 22 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs b/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs
index 67344061..c2857447 100644
--- a/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs
+++ b/Ryujinx.HLE/HOS/Services/Prepo/IPrepoService.cs
@@ -1,3 +1,4 @@
+using MsgPack;
using MsgPack.Serialization;
using Ryujinx.Common;
using Ryujinx.Common.Logging;
@@ -83,35 +84,21 @@ namespace Ryujinx.HLE.HOS.Services.Prepo
private string ReadReportBuffer(byte[] buffer, string room, UserId userId)
{
- StringBuilder sb = new StringBuilder();
+ StringBuilder builder = new StringBuilder();
+ MessagePackObject deserializedReport = MessagePackSerializer.UnpackMessagePackObject(buffer);
- sb.AppendLine();
- sb.AppendLine("PlayReport log:");
+ builder.AppendLine();
+ builder.AppendLine("PlayReport log:");
if (!userId.IsNull)
{
- sb.AppendLine($" UserId: {userId.ToString()}");
+ builder.AppendLine($" UserId: {userId.ToString()}");
}
- sb.AppendLine($" Room: {room}");
+ builder.AppendLine($" Room: {room}");
+ builder.AppendLine($" Report: {deserializedReport}");
- var deserializedReport = Deserialize<dynamic>(buffer);
- string jsonReport = Encoding.ASCII.GetString(JsonSerializer.PrettyPrintByteArray(Encoding.UTF8.GetBytes(deserializedReport.ToString())));
-
- sb.AppendLine($" Report:");
- sb.AppendLine(jsonReport);
-
- return sb.ToString();
- }
-
- private static T Deserialize<T>(byte[] bytes)
- {
- MessagePackSerializer serializer = MessagePackSerializer.Get<T>();
-
- using (MemoryStream byteStream = new MemoryStream(bytes))
- {
- return (T)serializer.Unpack(byteStream);
- }
+ return builder.ToString();
}
}
} \ No newline at end of file