diff --git a/SecondBotEvents/Commands/Avatars.cs b/SecondBotEvents/Commands/Avatars.cs index d3da313..511c89d 100644 --- a/SecondBotEvents/Commands/Avatars.cs +++ b/SecondBotEvents/Commands/Avatars.cs @@ -95,7 +95,7 @@ namespace SecondBotEvents.Commands BetterNearMe.Add(details); } } - return BasicReply(JsonSerializer.Serialize(BetterNearMe)); + return BasicReply(JsonSerializer.Serialize(BetterNearMe, JsonOptions.UnsafeRelaxed)); } [About("Requests the given avatars profile image")] @@ -228,7 +228,7 @@ namespace SecondBotEvents.Commands NearMe.Add(av.ID, av.Name); } } - return BasicReply(JsonSerializer.Serialize(NearMe)); + return BasicReply(JsonSerializer.Serialize(NearMe, JsonOptions.UnsafeRelaxed)); } [About("searchs the AV database if not found triggers a lookup")] diff --git a/SecondBotEvents/Commands/Chat.cs b/SecondBotEvents/Commands/Chat.cs index 0269b6a..0741df5 100644 --- a/SecondBotEvents/Commands/Chat.cs +++ b/SecondBotEvents/Commands/Chat.cs @@ -12,7 +12,7 @@ namespace SecondBotEvents.Commands [CmdTypeGet()] public object LocalChatHistory() { - return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetLocalChat())); + return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetLocalChat(), JsonOptions.UnsafeRelaxed)); } [About("sends a message to localchat (Normal chat)")] @@ -108,7 +108,7 @@ namespace SecondBotEvents.Commands [CmdTypeGet()] public object chatwindows() { - return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetAvatarImWindows())); + return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetAvatarImWindows(), JsonOptions.UnsafeRelaxed)); } [About("gets a list of chat windows from avatars with unread messages")] @@ -116,7 +116,7 @@ namespace SecondBotEvents.Commands [CmdTypeGet()] public object listwithunread() { - return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetAvatarImWindowsUnread())); + return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetAvatarImWindowsUnread(), JsonOptions.UnsafeRelaxed)); } [About("gets if there are any unread im messages from avatars at all")] @@ -139,7 +139,7 @@ namespace SecondBotEvents.Commands { return Failure("avatar UUID invaild"); } - return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetAvatarImWindow(avatarUUID))); + return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetAvatarImWindow(avatarUUID), JsonOptions.UnsafeRelaxed)); } } diff --git a/SecondBotEvents/Commands/Discord.cs b/SecondBotEvents/Commands/Discord.cs index 4260dc8..2423deb 100644 --- a/SecondBotEvents/Commands/Discord.cs +++ b/SecondBotEvents/Commands/Discord.cs @@ -63,7 +63,7 @@ namespace SecondBotEvents.Commands { return Failure(reply.Value.First()); } - return BasicReply(JsonSerializer.Serialize(reply.Value)); + return BasicReply(JsonSerializer.Serialize(reply.Value, JsonOptions.UnsafeRelaxed)); } [About("Clears messages on the server sent by the member in the last 13 days, 22hours 59mins")] diff --git a/SecondBotEvents/Commands/Estate.cs b/SecondBotEvents/Commands/Estate.cs index 0b1c3a5..3e8853d 100644 --- a/SecondBotEvents/Commands/Estate.cs +++ b/SecondBotEvents/Commands/Estate.cs @@ -380,7 +380,7 @@ namespace SecondBotEvents.Commands EstateName = result.EstateName.ToString(), EstateOwnerID = result.EstateOwnerID.ToString(), CovenantText = covenantAssetRead.Value - })); + }, JsonOptions.UnsafeRelaxed)); } [About("Sets the extended region info for the sim you are on")] @@ -638,7 +638,7 @@ namespace SecondBotEvents.Commands { "X", region.X.ToString() }, { "Y", region.Y.ToString() } }; - return BasicReply(JsonSerializer.Serialize(reply)); + return BasicReply(JsonSerializer.Serialize(reply, JsonOptions.UnsafeRelaxed)); } [About("Requests the estate banlist")] @@ -646,7 +646,7 @@ namespace SecondBotEvents.Commands [CmdTypeGet()] public object GetEstateBanList() { - return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetEstateBans())); + return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetEstateBans(), JsonOptions.UnsafeRelaxed)); } [About("Attempts to add/remove the avatar to/from the Estate banlist")] diff --git a/SecondBotEvents/Commands/Friends.cs b/SecondBotEvents/Commands/Friends.cs index 6e20fc5..6ef4a34 100644 --- a/SecondBotEvents/Commands/Friends.cs +++ b/SecondBotEvents/Commands/Friends.cs @@ -34,7 +34,7 @@ namespace SecondBotEvents.Commands { return Failure("no map access or updating", [avatar]); } - return BasicReply(JsonSerializer.Serialize(loc), [avatar]); + return BasicReply(JsonSerializer.Serialize(loc, JsonOptions.UnsafeRelaxed), [avatar]); } [About("Gets the friendslist")] @@ -56,7 +56,7 @@ namespace SecondBotEvents.Commands CleanedFriendsList.Add(entry); index++; } - return BasicReply(JsonSerializer.Serialize(CleanedFriendsList)); + return BasicReply(JsonSerializer.Serialize(CleanedFriendsList, JsonOptions.UnsafeRelaxed)); } [About("Updates the friend perms for avatar avatar to State \n if true grants (Online/Map/Modify) perms")] diff --git a/SecondBotEvents/Commands/Group.cs b/SecondBotEvents/Commands/Group.cs index 18fce65..c3da88d 100644 --- a/SecondBotEvents/Commands/Group.cs +++ b/SecondBotEvents/Commands/Group.cs @@ -41,7 +41,7 @@ namespace SecondBotEvents.Commands { return Failure("Invaild group UUID", [group]); } - return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetGroupMembers(groupuuid))); + return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetGroupMembers(groupuuid), JsonOptions.UnsafeRelaxed)); } [About("Attempts to ban/unban a given avatar from a group")] @@ -328,7 +328,7 @@ namespace SecondBotEvents.Commands [CmdTypeGet()] public object GetGroupList() { - return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetGroups())); + return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetGroups(), JsonOptions.UnsafeRelaxed)); } [About("Forces the bot to reload the groups list")] @@ -357,7 +357,7 @@ namespace SecondBotEvents.Commands { return Failure("Unknown group", [group]); } - return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetGroupRoles(groupuuid))); + return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetGroupRoles(groupuuid), JsonOptions.UnsafeRelaxed)); } [About("fetchs a list of all groups with unread messages")] @@ -365,7 +365,7 @@ namespace SecondBotEvents.Commands [CmdTypeGet()] public object GroupchatListAllUnreadGroups() { - return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetAllGroupsChatWithUnread())); + return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetAllGroupsChatWithUnread(), JsonOptions.UnsafeRelaxed)); } [About("checks if a given group has any unread messages")] @@ -416,7 +416,7 @@ namespace SecondBotEvents.Commands { return Failure("Group UUID invaild", [group]); } - return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetGroupChatHistory(groupUUID))); + return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetGroupChatHistory(groupUUID), JsonOptions.UnsafeRelaxed)); } [About("sends a message to the groupchat")] diff --git a/SecondBotEvents/Commands/Info.cs b/SecondBotEvents/Commands/Info.cs index 2705d8c..86159f9 100644 --- a/SecondBotEvents/Commands/Info.cs +++ b/SecondBotEvents/Commands/Info.cs @@ -82,7 +82,7 @@ namespace SecondBotEvents.Commands { return Failure("No objects found"); } - return BasicReply(JsonSerializer.Serialize(reply)); + return BasicReply(JsonSerializer.Serialize(reply, JsonOptions.UnsafeRelaxed)); } [About("Fetchs the current bot")] @@ -158,7 +158,7 @@ namespace SecondBotEvents.Commands { "y", (int)Math.Round(GetClient().Self.SimPosition.Y) }, { "z", (int)Math.Round(GetClient().Self.SimPosition.Z) } }; - return BasicReply(JsonSerializer.Serialize(pos)); + return BasicReply(JsonSerializer.Serialize(pos, JsonOptions.UnsafeRelaxed)); } } diff --git a/SecondBotEvents/Commands/Inventory.cs b/SecondBotEvents/Commands/Inventory.cs index 20e1471..a022256 100644 --- a/SecondBotEvents/Commands/Inventory.cs +++ b/SecondBotEvents/Commands/Inventory.cs @@ -1112,7 +1112,7 @@ namespace SecondBotEvents.Commands public object InventoryContentsCatched() { InventoryNodeEntry root = LoadInventoryNode(GetClient().Inventory.Store.RootFolder.UUID,"My Inventory"); - return BasicReply(JsonSerializer.Serialize(root)); + return BasicReply(JsonSerializer.Serialize(root, JsonOptions.UnsafeRelaxed)); } protected InventoryNodeEntry LoadInventoryNode(UUID folder, string name="") @@ -1284,7 +1284,7 @@ namespace SecondBotEvents.Commands } public string ToJson() { - return JsonSerializer.Serialize(this); + return JsonSerializer.Serialize(this, JsonOptions.UnsafeRelaxed); } } } diff --git a/SecondBotEvents/Commands/Notecard.cs b/SecondBotEvents/Commands/Notecard.cs index 92525eb..50773e6 100644 --- a/SecondBotEvents/Commands/Notecard.cs +++ b/SecondBotEvents/Commands/Notecard.cs @@ -33,20 +33,20 @@ namespace SecondBotEvents.Commands }; if (UUID.TryParse(notecardInventoryUUID, out var uuid) == false) { - master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply), "NotecardRead"); + master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply, JsonOptions.UnsafeRelaxed), "NotecardRead"); return Failure(reply.content, [notecardInventoryUUID]); } reply.content = "Unable to find inventory item"; InventoryItem item = GetClient().Inventory.FetchItem(uuid, GetClient().Self.AgentID, new System.TimeSpan(0, 1, 30)); if (item == null) { - master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply), "NotecardRead"); + master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply, JsonOptions.UnsafeRelaxed), "NotecardRead"); return Failure(reply.content, [notecardInventoryUUID]); } reply.content = "Inventory item is not a notecard"; if (item.InventoryType != InventoryType.Notecard) { - master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply), "NotecardRead"); + master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply, JsonOptions.UnsafeRelaxed), "NotecardRead"); return Failure(reply.content, [notecardInventoryUUID]); ; } InventoryNotecard notecard = (InventoryNotecard)item; @@ -55,7 +55,7 @@ namespace SecondBotEvents.Commands if (transfer.Success == false) { reply.content = "!ERROR! - unable to read notecard"; - master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply), "NotecardRead"); + master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply, JsonOptions.UnsafeRelaxed), "NotecardRead"); } else { @@ -77,7 +77,7 @@ namespace SecondBotEvents.Commands reply.content = contents; reply.name = notecard.Name; reply.status = true; - master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply), "NotecardRead"); + master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply, JsonOptions.UnsafeRelaxed), "NotecardRead"); } } ); diff --git a/SecondBotEvents/Commands/ParcelCommands.cs b/SecondBotEvents/Commands/ParcelCommands.cs index d4fff3a..12c643b 100644 --- a/SecondBotEvents/Commands/ParcelCommands.cs +++ b/SecondBotEvents/Commands/ParcelCommands.cs @@ -106,7 +106,7 @@ namespace SecondBotEvents.Commands { reply.Add(A.Name, A.SnapshotID.ToString()); } - return BasicReply(JsonSerializer.Serialize(reply)); + return BasicReply(JsonSerializer.Serialize(reply, JsonOptions.UnsafeRelaxed)); } [About("Requests the current parcel size")] @@ -245,7 +245,7 @@ namespace SecondBotEvents.Commands }; reply.parcels.Add(R); } - return BasicReply(JsonSerializer.Serialize(reply)); + return BasicReply(JsonSerializer.Serialize(reply, JsonOptions.UnsafeRelaxed)); } [About("Cancels the current parcel the bot is in sale")] @@ -341,7 +341,7 @@ namespace SecondBotEvents.Commands collection.Add("ForSale", targetparcel.Flags.HasFlag(ParcelFlags.ForSale).ToString()); collection.Add("Cost", targetparcel.SalePrice.ToString()); collection.Add("SaleTarget", targetparcel.AuthBuyerID.ToString()); - return BasicReply(JsonSerializer.Serialize(collection)); + return BasicReply(JsonSerializer.Serialize(collection, JsonOptions.UnsafeRelaxed)); } [About("Make a request to the landsale directory")] @@ -407,7 +407,7 @@ namespace SecondBotEvents.Commands int counter = (100 * GetpageNum); foreach(DirectoryParcel parcel in e.DirParcels) { - collection.Add(JsonSerializer.Serialize(parcel)); + collection.Add(JsonSerializer.Serialize(parcel, JsonOptions.UnsafeRelaxed)); counter++; } landresultsTimeout.Set(); @@ -422,7 +422,7 @@ namespace SecondBotEvents.Commands return Failure("Timed out while doing land search"); } GetClient().Directory.DirLandReply -= LandSearchResultsReply; - string reply = JsonSerializer.Serialize(collection); + string reply = JsonSerializer.Serialize(collection, JsonOptions.UnsafeRelaxed); return BasicReply(reply, [filterRegion, filterPrice, filterArea, pageNum, timeout]); } @@ -537,7 +537,7 @@ namespace SecondBotEvents.Commands { collection.Add(cfg.ToString(), targetparcel.Flags.HasFlag(cfg).ToString()); } - return BasicReply(JsonSerializer.Serialize(collection)); + return BasicReply(JsonSerializer.Serialize(collection, JsonOptions.UnsafeRelaxed)); } [About("Ejects an avatar")] @@ -785,7 +785,7 @@ namespace SecondBotEvents.Commands collection.Add("OtherPrims", targetparcel.OtherPrims.ToString()); collection.Add("MaxPrims", targetparcel.MaxPrims.ToString()); collection.Add("ParcelPrimBonus", targetparcel.ParcelPrimBonus.ToString()); - return BasicReply(JsonSerializer.Serialize(collection)); + return BasicReply(JsonSerializer.Serialize(collection, JsonOptions.UnsafeRelaxed)); } [About("Controls who can trigger audio on this parcel\n if everyone is set to true then grouponly will switch to false")] [ReturnHints("ok")] @@ -1064,7 +1064,7 @@ namespace SecondBotEvents.Commands reply.delay = delays * 1000; reply.parcelName = targetparcel.Name; reply.regionName = GetClient().Network.CurrentSim.Name; - return BasicReply(JsonSerializer.Serialize(reply)); + return BasicReply(JsonSerializer.Serialize(reply, JsonOptions.UnsafeRelaxed)); } [About("Returns a rezzed object")] @@ -1131,7 +1131,7 @@ namespace SecondBotEvents.Commands { return Failure("No objects found in the parcel"); } - return BasicReply(JsonSerializer.Serialize(objects)); + return BasicReply(JsonSerializer.Serialize(objects, JsonOptions.UnsafeRelaxed)); } [About("Updates the current parcels media settings \n" + diff --git a/SecondBotEvents/Commands/Self.cs b/SecondBotEvents/Commands/Self.cs index 3bc7de4..791e7f7 100644 --- a/SecondBotEvents/Commands/Self.cs +++ b/SecondBotEvents/Commands/Self.cs @@ -218,7 +218,7 @@ namespace SecondBotEvents.Commands List reply = []; foreach (CommandHistory A in master.DataStoreService.GetCommandHistory()) { - reply.Add(JsonSerializer.Serialize(A)); + reply.Add(JsonSerializer.Serialize(A, JsonOptions.UnsafeRelaxed)); if (reply.Count >= 5) { break; diff --git a/SecondBotEvents/Config/config.cs b/SecondBotEvents/Config/config.cs index f77ed55..d93f37d 100644 --- a/SecondBotEvents/Config/config.cs +++ b/SecondBotEvents/Config/config.cs @@ -1,11 +1,12 @@ -using System.Text.Json; -using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Linq; +using SecondBotEvents.Services; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Runtime; using System.Text; +using System.Text.Json; namespace SecondBotEvents.Config @@ -76,7 +77,7 @@ namespace SecondBotEvents.Config SimpleIO IO = new(); IO.ChangeRoot(fromFolder); string writeFile = filename + ".json"; - IO.WriteFile(writeFile, JsonSerializer.Serialize(saveMe)); + IO.WriteFile(writeFile, JsonSerializer.Serialize(saveMe, JsonOptions.UnsafeRelaxed)); } protected void LoadSettingsFromFile(string fromFolder) diff --git a/SecondBotEvents/Services/ChatGptService.cs b/SecondBotEvents/Services/ChatGptService.cs index 4534fb3..1977d4d 100644 --- a/SecondBotEvents/Services/ChatGptService.cs +++ b/SecondBotEvents/Services/ChatGptService.cs @@ -431,7 +431,7 @@ namespace SecondBotEvents.Services RedisKey writekey = new(myConfig.GetRedisPrefix() + store.Guid.ToString()); try { - string savestring = JsonSerializer.Serialize(history); + string savestring = JsonSerializer.Serialize(history, JsonOptions.UnsafeRelaxed); if (savestring == null) { LogFormater.Warn("Redis failed to convert history into savable format"); diff --git a/SecondBotEvents/Services/CommandsService.cs b/SecondBotEvents/Services/CommandsService.cs index a989a00..14912c4 100644 --- a/SecondBotEvents/Services/CommandsService.cs +++ b/SecondBotEvents/Services/CommandsService.cs @@ -326,11 +326,7 @@ namespace SecondBotEvents.Services reply = "Error"; if (processed != null) { - var options = new JsonSerializerOptions - { - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - }; - reply = JsonSerializer.Serialize(processed, options); + reply = JsonSerializer.Serialize(processed, JsonOptions.UnsafeRelaxed); } CommandNotice(C.command, source, String.Join("@@@", C.args), true, reply); return new KeyValuePair(status, reply); @@ -448,17 +444,13 @@ namespace SecondBotEvents.Services BotCommandNotice e = new(command, args, source, accepted, results); EventHandler handler = BotclientCommandEventNotices; handler?.Invoke(this, e); - if (myConfig.GetCommandHistoryLogResults() == false) - { - return; - } if (master.BotClient.basicCfg.GetLogCommands() == true) { - if(e.results.Length >= 100) + if (myConfig.GetCommandHistoryLogResults() == false) { - e.results = e.results.Substring(0, 100) + "..."; + e.results = "~hidden~"; } - LogFormater.Info("Command log:" + JsonSerializer.Serialize(e)); + LogFormater.Info("Command log:" + JsonSerializer.Serialize(e, JsonOptions.UnsafeRelaxed)); } } } @@ -618,4 +610,12 @@ namespace SecondBotEvents.Services return (T)ret; } } + + public static class JsonOptions + { + public static readonly JsonSerializerOptions UnsafeRelaxed = new() + { + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping + }; + } } diff --git a/SecondBotEvents/Services/DialogService.cs b/SecondBotEvents/Services/DialogService.cs index a9e1557..1a69ba6 100644 --- a/SecondBotEvents/Services/DialogService.cs +++ b/SecondBotEvents/Services/DialogService.cs @@ -190,7 +190,7 @@ namespace SecondBotEvents.Services objectname = e.ObjectName, expires = expiresAt }; - string eventMessage = JsonSerializer.Serialize(window); + string eventMessage = JsonSerializer.Serialize(window, JsonOptions.UnsafeRelaxed); foreach(int a in DialogRelayChannels) { if(a >= 0) diff --git a/SecondBotEvents/Services/EventsService.cs b/SecondBotEvents/Services/EventsService.cs index f81995f..33246b4 100644 --- a/SecondBotEvents/Services/EventsService.cs +++ b/SecondBotEvents/Services/EventsService.cs @@ -37,7 +37,7 @@ namespace SecondBotEvents.Services { foreach (string A in targets) { - string output = JsonSerializer.Serialize(detail); + string output = JsonSerializer.Serialize(detail, JsonOptions.UnsafeRelaxed); if (UUID.TryParse(A, out UUID OutputAvatar) == true) { if (OutputAvatar != UUID.Zero) @@ -264,7 +264,7 @@ namespace SecondBotEvents.Services args, myConfig.GetOutputSecret() ); - string output = JsonSerializer.Serialize(e); + string output = JsonSerializer.Serialize(e, JsonOptions.UnsafeRelaxed); if(myConfig.GetOutputChannel() >= 0) { GetClient().Self.Chat(output, myConfig.GetOutputChannel(), ChatType.Normal); diff --git a/SecondBotEvents/Services/HttpService.cs b/SecondBotEvents/Services/HttpService.cs index 2c4317a..60b291a 100644 --- a/SecondBotEvents/Services/HttpService.cs +++ b/SecondBotEvents/Services/HttpService.cs @@ -159,7 +159,7 @@ namespace SecondBotEvents.Services { return "Command request rejected"; } - return JsonSerializer.Serialize(master.CommandsService.RunCommand("HTTP", C)); + return JsonSerializer.Serialize(master.CommandsService.RunCommand("HTTP", C), JsonOptions.UnsafeRelaxed); } public static async Task SerializationCallback(IHttpContext context, object? data) { @@ -384,7 +384,7 @@ namespace SecondBotEvents.Services { return "Command request rejected"; } - return JsonSerializer.Serialize(master.CommandsService.RunCommand("HTTP",C)); + return JsonSerializer.Serialize(master.CommandsService.RunCommand("HTTP",C), JsonOptions.UnsafeRelaxed); } } diff --git a/SecondBotEvents/Services/InteractionService.cs b/SecondBotEvents/Services/InteractionService.cs index 63a5355..a4ae5c0 100644 --- a/SecondBotEvents/Services/InteractionService.cs +++ b/SecondBotEvents/Services/InteractionService.cs @@ -145,7 +145,7 @@ namespace SecondBotEvents.Services { if(myConfig.GetEnableDebug() == true) { - LogFormater.Warn("Interaction debug:" + JsonSerializer.Serialize(new InteractionEvent(from, eventype, status, why, setMisc))); + LogFormater.Warn("Interaction debug:" + JsonSerializer.Serialize(new InteractionEvent(from, eventype, status, why, setMisc), JsonOptions.UnsafeRelaxed)); } if (myConfig.GetEnableJsonOutputEvents() == false) { @@ -153,7 +153,7 @@ namespace SecondBotEvents.Services } master.CommandsService.SmartCommandReply( myConfig.GetJsonOutputEventsTarget(), - JsonSerializer.Serialize(new InteractionEvent(from, eventype, status, why, setMisc)), + JsonSerializer.Serialize(new InteractionEvent(from, eventype, status, why, setMisc), JsonOptions.UnsafeRelaxed), "interactions" ); } @@ -171,7 +171,7 @@ namespace SecondBotEvents.Services { if (myConfig.GetEnableDebug() == true) { - LogFormater.Warn("Interaction debug:" + JsonSerializer.Serialize(misc)); + LogFormater.Warn("Interaction debug:" + JsonSerializer.Serialize(misc, JsonOptions.UnsafeRelaxed)); } if (myConfig.GetEnableJsonOutputEvents() == false) { @@ -180,7 +180,7 @@ namespace SecondBotEvents.Services misc.Add("eventsource", source); master.CommandsService.SmartCommandReply( myConfig.GetJsonOutputEventsTarget(), - JsonSerializer.Serialize(misc), + JsonSerializer.Serialize(misc, JsonOptions.UnsafeRelaxed), "interactions" ); } diff --git a/SecondBotEvents/Services/RelayService.cs b/SecondBotEvents/Services/RelayService.cs index 38bf6c1..b22730d 100644 --- a/SecondBotEvents/Services/RelayService.cs +++ b/SecondBotEvents/Services/RelayService.cs @@ -218,7 +218,7 @@ namespace SecondBotEvents.Services sourcetype = source, sourceoption = filter }; - string eventMessage = JsonSerializer.Serialize(a); + string eventMessage = JsonSerializer.Serialize(a, JsonOptions.UnsafeRelaxed); relayEventExtended relayEventExtended = new() { source = source, @@ -230,7 +230,7 @@ namespace SecondBotEvents.Services message = message, unixtime = SecondbotHelpers.UnixTimeNow().ToString() }; - string eventMessageExtended = JsonSerializer.Serialize(relayEventExtended); + string eventMessageExtended = JsonSerializer.Serialize(relayEventExtended, JsonOptions.UnsafeRelaxed); while (loop <= myConfig.GetRelayCount()) { diff --git a/SecondBotEvents/Static/Inventory.cs b/SecondBotEvents/Static/Inventory.cs index e9017c0..81e1de0 100644 --- a/SecondBotEvents/Static/Inventory.cs +++ b/SecondBotEvents/Static/Inventory.cs @@ -1,9 +1,10 @@ -using System.Text.Json; -using OpenMetaverse; +using OpenMetaverse; using OpenMetaverse.ImportExport.Collada14; +using SecondBotEvents.Services; using System; using System.Collections.Generic; using System.Text; +using System.Text.Json; namespace BetterSecondBot.Static { @@ -146,7 +147,7 @@ namespace BetterSecondBot.Static } public static string MapFolderInventoryJson(GridClient bot,UUID folder) { - return JsonSerializer.Serialize(getfolderinventory(bot, folder)); + return JsonSerializer.Serialize(getfolderinventory(bot, folder), JsonOptions.UnsafeRelaxed); } public static KeyValuePair MapFolderInventoryHumanReadable(GridClient bot, UUID folder) @@ -192,7 +193,7 @@ namespace BetterSecondBot.Static } if (topLevel != null) { - return JsonSerializer.Serialize(DoMapFolderJson(bot, topLevel, subfolders)); + return JsonSerializer.Serialize(DoMapFolderJson(bot, topLevel, subfolders), JsonOptions.UnsafeRelaxed); } } }