From 811baa74bc029740359afa43cb2727fe647c2d98 Mon Sep 17 00:00:00 2001 From: Madpeter <57852827+Madpeterz@users.noreply.github.com> Date: Sun, 5 Oct 2025 19:36:14 +0100 Subject: [PATCH] Use relaxed JSON escaping for command replies Updated JSON serialization in CommandsService to use UnsafeRelaxedJsonEscaping for replies, ensuring special characters are not escaped unnecessarily when sending processed command results. --- SecondBotEvents/Services/CommandsService.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/SecondBotEvents/Services/CommandsService.cs b/SecondBotEvents/Services/CommandsService.cs index 1a3b1f4..a989a00 100644 --- a/SecondBotEvents/Services/CommandsService.cs +++ b/SecondBotEvents/Services/CommandsService.cs @@ -1,15 +1,16 @@ -using System.Text.Json; -using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Linq; using OpenMetaverse; +using OpenMetaverse.ImportExport.Collada14; using SecondBotEvents.Config; using System; using System.Collections.Generic; -using System.Text; -using System.Linq; -using System.Reflection; -using System.Net.Http; -using OpenMetaverse.ImportExport.Collada14; using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Net.Http; +using System.Reflection; +using System.Text; +using System.Text.Encodings.Web; +using System.Text.Json; namespace SecondBotEvents.Services { @@ -325,7 +326,11 @@ namespace SecondBotEvents.Services reply = "Error"; if (processed != null) { - reply = JsonSerializer.Serialize(processed); + var options = new JsonSerializerOptions + { + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping + }; + reply = JsonSerializer.Serialize(processed, options); } CommandNotice(C.command, source, String.Join("@@@", C.args), true, reply); return new KeyValuePair(status, reply);