From 8ce7465177855f29c1ee5530082c43d10a86c7a8 Mon Sep 17 00:00:00 2001 From: spiral Date: Sun, 23 Jan 2022 01:47:55 -0500 Subject: [PATCH] fix: don't crash in lists when searching for a string longer than 256 characters --- PluralKit.Bot/Commands/GroupMember.cs | 4 +++- PluralKit.Bot/Commands/Lists/ListOptions.cs | 4 +++- PluralKit.Bot/Commands/SystemList.cs | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/PluralKit.Bot/Commands/GroupMember.cs b/PluralKit.Bot/Commands/GroupMember.cs index 02a6f8b5..cdbcfce1 100644 --- a/PluralKit.Bot/Commands/GroupMember.cs +++ b/PluralKit.Bot/Commands/GroupMember.cs @@ -1,5 +1,7 @@ using System.Text; +using Humanizer; + using Myriad.Builders; using PluralKit.Core; @@ -134,7 +136,7 @@ public class GroupMember else title.Append($"`{targetSystem.Hid}`"); if (opts.Search != null) - title.Append($" matching **{opts.Search}**"); + title.Append($" matching **{opts.Search.Truncate(100)}**"); await ctx.RenderMemberList(ctx.LookupContextFor(target.System), target.System, title.ToString(), target.Color, opts); diff --git a/PluralKit.Bot/Commands/Lists/ListOptions.cs b/PluralKit.Bot/Commands/Lists/ListOptions.cs index c42ccc1e..39e12367 100644 --- a/PluralKit.Bot/Commands/Lists/ListOptions.cs +++ b/PluralKit.Bot/Commands/Lists/ListOptions.cs @@ -1,5 +1,7 @@ using System.Text; +using Humanizer; + using NodaTime; using PluralKit.Core; @@ -47,7 +49,7 @@ public class ListOptions if (Search != null) { - str.Append($", searching for \"{Search}\""); + str.Append($", searching for \"{Search.Truncate(100)}\""); if (SearchDescription) str.Append(" (including description)"); } diff --git a/PluralKit.Bot/Commands/SystemList.cs b/PluralKit.Bot/Commands/SystemList.cs index 88111684..ba68fe26 100644 --- a/PluralKit.Bot/Commands/SystemList.cs +++ b/PluralKit.Bot/Commands/SystemList.cs @@ -1,5 +1,7 @@ using System.Text; +using Humanizer; + using PluralKit.Core; namespace PluralKit.Bot; @@ -35,7 +37,7 @@ public class SystemList title.Append($"`{target.Hid}`"); if (opts.Search != null) - title.Append($" matching **{opts.Search}**"); + title.Append($" matching **{opts.Search.Truncate(100)}**"); return title.ToString(); }