Use UnsafeRelaxed JSON serialization globally

Replaces all usages of JsonSerializer.Serialize with the UnsafeRelaxed option via a new JsonOptions.UnsafeRelaxed static property. This ensures consistent relaxed escaping for all JSON output, improving compatibility with consumers expecting unescaped JSON. Refactors affected command, service, and static classes to use the new option.
This commit is contained in:
Madpeter 2025-10-05 20:07:42 +01:00
parent 811baa74bc
commit 008cb44e24
20 changed files with 69 additions and 67 deletions

View file

@ -95,7 +95,7 @@ namespace SecondBotEvents.Commands
BetterNearMe.Add(details); BetterNearMe.Add(details);
} }
} }
return BasicReply(JsonSerializer.Serialize(BetterNearMe)); return BasicReply(JsonSerializer.Serialize(BetterNearMe, JsonOptions.UnsafeRelaxed));
} }
[About("Requests the given avatars profile image")] [About("Requests the given avatars profile image")]
@ -228,7 +228,7 @@ namespace SecondBotEvents.Commands
NearMe.Add(av.ID, av.Name); 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")] [About("searchs the AV database if not found triggers a lookup")]

View file

@ -12,7 +12,7 @@ namespace SecondBotEvents.Commands
[CmdTypeGet()] [CmdTypeGet()]
public object LocalChatHistory() 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)")] [About("sends a message to localchat (Normal chat)")]
@ -108,7 +108,7 @@ namespace SecondBotEvents.Commands
[CmdTypeGet()] [CmdTypeGet()]
public object chatwindows() 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")] [About("gets a list of chat windows from avatars with unread messages")]
@ -116,7 +116,7 @@ namespace SecondBotEvents.Commands
[CmdTypeGet()] [CmdTypeGet()]
public object listwithunread() 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")] [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 Failure("avatar UUID invaild");
} }
return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetAvatarImWindow(avatarUUID))); return BasicReply(JsonSerializer.Serialize(master.DataStoreService.GetAvatarImWindow(avatarUUID), JsonOptions.UnsafeRelaxed));
} }
} }

View file

@ -63,7 +63,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure(reply.Value.First()); 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")] [About("Clears messages on the server sent by the member in the last 13 days, 22hours 59mins")]

View file

@ -380,7 +380,7 @@ namespace SecondBotEvents.Commands
EstateName = result.EstateName.ToString(), EstateName = result.EstateName.ToString(),
EstateOwnerID = result.EstateOwnerID.ToString(), EstateOwnerID = result.EstateOwnerID.ToString(),
CovenantText = covenantAssetRead.Value CovenantText = covenantAssetRead.Value
})); }, JsonOptions.UnsafeRelaxed));
} }
[About("Sets the extended region info for the sim you are on")] [About("Sets the extended region info for the sim you are on")]
@ -638,7 +638,7 @@ namespace SecondBotEvents.Commands
{ "X", region.X.ToString() }, { "X", region.X.ToString() },
{ "Y", region.Y.ToString() } { "Y", region.Y.ToString() }
}; };
return BasicReply(JsonSerializer.Serialize(reply)); return BasicReply(JsonSerializer.Serialize(reply, JsonOptions.UnsafeRelaxed));
} }
[About("Requests the estate banlist")] [About("Requests the estate banlist")]
@ -646,7 +646,7 @@ namespace SecondBotEvents.Commands
[CmdTypeGet()] [CmdTypeGet()]
public object GetEstateBanList() 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")] [About("Attempts to add/remove the avatar to/from the Estate banlist")]

View file

@ -34,7 +34,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("no map access or updating", [avatar]); 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")] [About("Gets the friendslist")]
@ -56,7 +56,7 @@ namespace SecondBotEvents.Commands
CleanedFriendsList.Add(entry); CleanedFriendsList.Add(entry);
index++; 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")] [About("Updates the friend perms for avatar avatar to State \n if true grants (Online/Map/Modify) perms")]

View file

@ -41,7 +41,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Invaild group UUID", [group]); 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")] [About("Attempts to ban/unban a given avatar from a group")]
@ -328,7 +328,7 @@ namespace SecondBotEvents.Commands
[CmdTypeGet()] [CmdTypeGet()]
public object GetGroupList() 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")] [About("Forces the bot to reload the groups list")]
@ -357,7 +357,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Unknown group", [group]); 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")] [About("fetchs a list of all groups with unread messages")]
@ -365,7 +365,7 @@ namespace SecondBotEvents.Commands
[CmdTypeGet()] [CmdTypeGet()]
public object GroupchatListAllUnreadGroups() 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")] [About("checks if a given group has any unread messages")]
@ -416,7 +416,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("Group UUID invaild", [group]); 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")] [About("sends a message to the groupchat")]

View file

@ -82,7 +82,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("No objects found"); return Failure("No objects found");
} }
return BasicReply(JsonSerializer.Serialize(reply)); return BasicReply(JsonSerializer.Serialize(reply, JsonOptions.UnsafeRelaxed));
} }
[About("Fetchs the current bot")] [About("Fetchs the current bot")]
@ -158,7 +158,7 @@ namespace SecondBotEvents.Commands
{ "y", (int)Math.Round(GetClient().Self.SimPosition.Y) }, { "y", (int)Math.Round(GetClient().Self.SimPosition.Y) },
{ "z", (int)Math.Round(GetClient().Self.SimPosition.Z) } { "z", (int)Math.Round(GetClient().Self.SimPosition.Z) }
}; };
return BasicReply(JsonSerializer.Serialize(pos)); return BasicReply(JsonSerializer.Serialize(pos, JsonOptions.UnsafeRelaxed));
} }
} }

View file

@ -1112,7 +1112,7 @@ namespace SecondBotEvents.Commands
public object InventoryContentsCatched() public object InventoryContentsCatched()
{ {
InventoryNodeEntry root = LoadInventoryNode(GetClient().Inventory.Store.RootFolder.UUID,"My Inventory"); 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="") protected InventoryNodeEntry LoadInventoryNode(UUID folder, string name="")
@ -1284,7 +1284,7 @@ namespace SecondBotEvents.Commands
} }
public string ToJson() public string ToJson()
{ {
return JsonSerializer.Serialize(this); return JsonSerializer.Serialize(this, JsonOptions.UnsafeRelaxed);
} }
} }
} }

View file

@ -33,20 +33,20 @@ namespace SecondBotEvents.Commands
}; };
if (UUID.TryParse(notecardInventoryUUID, out var uuid) == false) 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]); return Failure(reply.content, [notecardInventoryUUID]);
} }
reply.content = "Unable to find inventory item"; reply.content = "Unable to find inventory item";
InventoryItem item = GetClient().Inventory.FetchItem(uuid, GetClient().Self.AgentID, new System.TimeSpan(0, 1, 30)); InventoryItem item = GetClient().Inventory.FetchItem(uuid, GetClient().Self.AgentID, new System.TimeSpan(0, 1, 30));
if (item == null) 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]); return Failure(reply.content, [notecardInventoryUUID]);
} }
reply.content = "Inventory item is not a notecard"; reply.content = "Inventory item is not a notecard";
if (item.InventoryType != InventoryType.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]); ; return Failure(reply.content, [notecardInventoryUUID]); ;
} }
InventoryNotecard notecard = (InventoryNotecard)item; InventoryNotecard notecard = (InventoryNotecard)item;
@ -55,7 +55,7 @@ namespace SecondBotEvents.Commands
if (transfer.Success == false) if (transfer.Success == false)
{ {
reply.content = "!ERROR! - unable to read notecard"; 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 else
{ {
@ -77,7 +77,7 @@ namespace SecondBotEvents.Commands
reply.content = contents; reply.content = contents;
reply.name = notecard.Name; reply.name = notecard.Name;
reply.status = true; reply.status = true;
master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply), "NotecardRead"); master.CommandsService.SmartCommandReply(replytarget, JsonSerializer.Serialize(reply, JsonOptions.UnsafeRelaxed), "NotecardRead");
} }
} }
); );

View file

@ -106,7 +106,7 @@ namespace SecondBotEvents.Commands
{ {
reply.Add(A.Name, A.SnapshotID.ToString()); 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")] [About("Requests the current parcel size")]
@ -245,7 +245,7 @@ namespace SecondBotEvents.Commands
}; };
reply.parcels.Add(R); 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")] [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("ForSale", targetparcel.Flags.HasFlag(ParcelFlags.ForSale).ToString());
collection.Add("Cost", targetparcel.SalePrice.ToString()); collection.Add("Cost", targetparcel.SalePrice.ToString());
collection.Add("SaleTarget", targetparcel.AuthBuyerID.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")] [About("Make a request to the landsale directory")]
@ -407,7 +407,7 @@ namespace SecondBotEvents.Commands
int counter = (100 * GetpageNum); int counter = (100 * GetpageNum);
foreach(DirectoryParcel parcel in e.DirParcels) foreach(DirectoryParcel parcel in e.DirParcels)
{ {
collection.Add(JsonSerializer.Serialize(parcel)); collection.Add(JsonSerializer.Serialize(parcel, JsonOptions.UnsafeRelaxed));
counter++; counter++;
} }
landresultsTimeout.Set(); landresultsTimeout.Set();
@ -422,7 +422,7 @@ namespace SecondBotEvents.Commands
return Failure("Timed out while doing land search"); return Failure("Timed out while doing land search");
} }
GetClient().Directory.DirLandReply -= LandSearchResultsReply; GetClient().Directory.DirLandReply -= LandSearchResultsReply;
string reply = JsonSerializer.Serialize(collection); string reply = JsonSerializer.Serialize(collection, JsonOptions.UnsafeRelaxed);
return BasicReply(reply, [filterRegion, filterPrice, filterArea, pageNum, timeout]); return BasicReply(reply, [filterRegion, filterPrice, filterArea, pageNum, timeout]);
} }
@ -537,7 +537,7 @@ namespace SecondBotEvents.Commands
{ {
collection.Add(cfg.ToString(), targetparcel.Flags.HasFlag(cfg).ToString()); 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")] [About("Ejects an avatar")]
@ -785,7 +785,7 @@ namespace SecondBotEvents.Commands
collection.Add("OtherPrims", targetparcel.OtherPrims.ToString()); collection.Add("OtherPrims", targetparcel.OtherPrims.ToString());
collection.Add("MaxPrims", targetparcel.MaxPrims.ToString()); collection.Add("MaxPrims", targetparcel.MaxPrims.ToString());
collection.Add("ParcelPrimBonus", targetparcel.ParcelPrimBonus.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")] [About("Controls who can trigger audio on this parcel\n if everyone is set to true then grouponly will switch to false")]
[ReturnHints("ok")] [ReturnHints("ok")]
@ -1064,7 +1064,7 @@ namespace SecondBotEvents.Commands
reply.delay = delays * 1000; reply.delay = delays * 1000;
reply.parcelName = targetparcel.Name; reply.parcelName = targetparcel.Name;
reply.regionName = GetClient().Network.CurrentSim.Name; reply.regionName = GetClient().Network.CurrentSim.Name;
return BasicReply(JsonSerializer.Serialize(reply)); return BasicReply(JsonSerializer.Serialize(reply, JsonOptions.UnsafeRelaxed));
} }
[About("Returns a rezzed object")] [About("Returns a rezzed object")]
@ -1131,7 +1131,7 @@ namespace SecondBotEvents.Commands
{ {
return Failure("No objects found in the parcel"); 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" + [About("Updates the current parcels media settings \n" +

View file

@ -218,7 +218,7 @@ namespace SecondBotEvents.Commands
List<string> reply = []; List<string> reply = [];
foreach (CommandHistory A in master.DataStoreService.GetCommandHistory()) foreach (CommandHistory A in master.DataStoreService.GetCommandHistory())
{ {
reply.Add(JsonSerializer.Serialize(A)); reply.Add(JsonSerializer.Serialize(A, JsonOptions.UnsafeRelaxed));
if (reply.Count >= 5) if (reply.Count >= 5)
{ {
break; break;

View file

@ -1,11 +1,12 @@
using System.Text.Json; using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Linq; using SecondBotEvents.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime; using System.Runtime;
using System.Text; using System.Text;
using System.Text.Json;
namespace SecondBotEvents.Config namespace SecondBotEvents.Config
@ -76,7 +77,7 @@ namespace SecondBotEvents.Config
SimpleIO IO = new(); SimpleIO IO = new();
IO.ChangeRoot(fromFolder); IO.ChangeRoot(fromFolder);
string writeFile = filename + ".json"; string writeFile = filename + ".json";
IO.WriteFile(writeFile, JsonSerializer.Serialize(saveMe)); IO.WriteFile(writeFile, JsonSerializer.Serialize(saveMe, JsonOptions.UnsafeRelaxed));
} }
protected void LoadSettingsFromFile(string fromFolder) protected void LoadSettingsFromFile(string fromFolder)

View file

@ -431,7 +431,7 @@ namespace SecondBotEvents.Services
RedisKey writekey = new(myConfig.GetRedisPrefix() + store.Guid.ToString()); RedisKey writekey = new(myConfig.GetRedisPrefix() + store.Guid.ToString());
try try
{ {
string savestring = JsonSerializer.Serialize(history); string savestring = JsonSerializer.Serialize(history, JsonOptions.UnsafeRelaxed);
if (savestring == null) if (savestring == null)
{ {
LogFormater.Warn("Redis failed to convert history into savable format"); LogFormater.Warn("Redis failed to convert history into savable format");

View file

@ -326,11 +326,7 @@ namespace SecondBotEvents.Services
reply = "Error"; reply = "Error";
if (processed != null) if (processed != null)
{ {
var options = new JsonSerializerOptions reply = JsonSerializer.Serialize(processed, JsonOptions.UnsafeRelaxed);
{
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
};
reply = JsonSerializer.Serialize(processed, options);
} }
CommandNotice(C.command, source, String.Join("@@@", C.args), true, reply); CommandNotice(C.command, source, String.Join("@@@", C.args), true, reply);
return new KeyValuePair<bool, string>(status, reply); return new KeyValuePair<bool, string>(status, reply);
@ -448,17 +444,13 @@ namespace SecondBotEvents.Services
BotCommandNotice e = new(command, args, source, accepted, results); BotCommandNotice e = new(command, args, source, accepted, results);
EventHandler<BotCommandNotice> handler = BotclientCommandEventNotices; EventHandler<BotCommandNotice> handler = BotclientCommandEventNotices;
handler?.Invoke(this, e); handler?.Invoke(this, e);
if (myConfig.GetCommandHistoryLogResults() == false)
{
return;
}
if (master.BotClient.basicCfg.GetLogCommands() == true) 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; return (T)ret;
} }
} }
public static class JsonOptions
{
public static readonly JsonSerializerOptions UnsafeRelaxed = new()
{
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
};
}
} }

View file

@ -190,7 +190,7 @@ namespace SecondBotEvents.Services
objectname = e.ObjectName, objectname = e.ObjectName,
expires = expiresAt expires = expiresAt
}; };
string eventMessage = JsonSerializer.Serialize(window); string eventMessage = JsonSerializer.Serialize(window, JsonOptions.UnsafeRelaxed);
foreach(int a in DialogRelayChannels) foreach(int a in DialogRelayChannels)
{ {
if(a >= 0) if(a >= 0)

View file

@ -37,7 +37,7 @@ namespace SecondBotEvents.Services
{ {
foreach (string A in targets) 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 (UUID.TryParse(A, out UUID OutputAvatar) == true)
{ {
if (OutputAvatar != UUID.Zero) if (OutputAvatar != UUID.Zero)
@ -264,7 +264,7 @@ namespace SecondBotEvents.Services
args, args,
myConfig.GetOutputSecret() myConfig.GetOutputSecret()
); );
string output = JsonSerializer.Serialize(e); string output = JsonSerializer.Serialize(e, JsonOptions.UnsafeRelaxed);
if(myConfig.GetOutputChannel() >= 0) if(myConfig.GetOutputChannel() >= 0)
{ {
GetClient().Self.Chat(output, myConfig.GetOutputChannel(), ChatType.Normal); GetClient().Self.Chat(output, myConfig.GetOutputChannel(), ChatType.Normal);

View file

@ -159,7 +159,7 @@ namespace SecondBotEvents.Services
{ {
return "Command request rejected"; 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) public static async Task SerializationCallback(IHttpContext context, object? data)
{ {
@ -384,7 +384,7 @@ namespace SecondBotEvents.Services
{ {
return "Command request rejected"; return "Command request rejected";
} }
return JsonSerializer.Serialize(master.CommandsService.RunCommand("HTTP",C)); return JsonSerializer.Serialize(master.CommandsService.RunCommand("HTTP",C), JsonOptions.UnsafeRelaxed);
} }
} }

View file

@ -145,7 +145,7 @@ namespace SecondBotEvents.Services
{ {
if(myConfig.GetEnableDebug() == true) 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) if (myConfig.GetEnableJsonOutputEvents() == false)
{ {
@ -153,7 +153,7 @@ namespace SecondBotEvents.Services
} }
master.CommandsService.SmartCommandReply( master.CommandsService.SmartCommandReply(
myConfig.GetJsonOutputEventsTarget(), myConfig.GetJsonOutputEventsTarget(),
JsonSerializer.Serialize(new InteractionEvent(from, eventype, status, why, setMisc)), JsonSerializer.Serialize(new InteractionEvent(from, eventype, status, why, setMisc), JsonOptions.UnsafeRelaxed),
"interactions" "interactions"
); );
} }
@ -171,7 +171,7 @@ namespace SecondBotEvents.Services
{ {
if (myConfig.GetEnableDebug() == true) if (myConfig.GetEnableDebug() == true)
{ {
LogFormater.Warn("Interaction debug:" + JsonSerializer.Serialize(misc)); LogFormater.Warn("Interaction debug:" + JsonSerializer.Serialize(misc, JsonOptions.UnsafeRelaxed));
} }
if (myConfig.GetEnableJsonOutputEvents() == false) if (myConfig.GetEnableJsonOutputEvents() == false)
{ {
@ -180,7 +180,7 @@ namespace SecondBotEvents.Services
misc.Add("eventsource", source); misc.Add("eventsource", source);
master.CommandsService.SmartCommandReply( master.CommandsService.SmartCommandReply(
myConfig.GetJsonOutputEventsTarget(), myConfig.GetJsonOutputEventsTarget(),
JsonSerializer.Serialize(misc), JsonSerializer.Serialize(misc, JsonOptions.UnsafeRelaxed),
"interactions" "interactions"
); );
} }

View file

@ -218,7 +218,7 @@ namespace SecondBotEvents.Services
sourcetype = source, sourcetype = source,
sourceoption = filter sourceoption = filter
}; };
string eventMessage = JsonSerializer.Serialize(a); string eventMessage = JsonSerializer.Serialize(a, JsonOptions.UnsafeRelaxed);
relayEventExtended relayEventExtended = new() relayEventExtended relayEventExtended = new()
{ {
source = source, source = source,
@ -230,7 +230,7 @@ namespace SecondBotEvents.Services
message = message, message = message,
unixtime = SecondbotHelpers.UnixTimeNow().ToString() unixtime = SecondbotHelpers.UnixTimeNow().ToString()
}; };
string eventMessageExtended = JsonSerializer.Serialize(relayEventExtended); string eventMessageExtended = JsonSerializer.Serialize(relayEventExtended, JsonOptions.UnsafeRelaxed);
while (loop <= myConfig.GetRelayCount()) while (loop <= myConfig.GetRelayCount())
{ {

View file

@ -1,9 +1,10 @@
using System.Text.Json; using OpenMetaverse;
using OpenMetaverse;
using OpenMetaverse.ImportExport.Collada14; using OpenMetaverse.ImportExport.Collada14;
using SecondBotEvents.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Text.Json;
namespace BetterSecondBot.Static namespace BetterSecondBot.Static
{ {
@ -146,7 +147,7 @@ namespace BetterSecondBot.Static
} }
public static string MapFolderInventoryJson(GridClient bot,UUID folder) 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<string,string> MapFolderInventoryHumanReadable(GridClient bot, UUID folder) public static KeyValuePair<string,string> MapFolderInventoryHumanReadable(GridClient bot, UUID folder)
@ -192,7 +193,7 @@ namespace BetterSecondBot.Static
} }
if (topLevel != null) if (topLevel != null)
{ {
return JsonSerializer.Serialize(DoMapFolderJson(bot, topLevel, subfolders)); return JsonSerializer.Serialize(DoMapFolderJson(bot, topLevel, subfolders), JsonOptions.UnsafeRelaxed);
} }
} }
} }