From 42235cef9c507b9b1b2e7e55eb9d81385cce6973 Mon Sep 17 00:00:00 2001 From: Petal Ladenson Date: Fri, 4 Oct 2024 10:43:36 -0600 Subject: [PATCH] fix(bot): don't add spaces to multiline proxy tags --- PluralKit.Bot/Commands/MemberProxy.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/PluralKit.Bot/Commands/MemberProxy.cs b/PluralKit.Bot/Commands/MemberProxy.cs index 02ee4555..e1bcb19b 100644 --- a/PluralKit.Bot/Commands/MemberProxy.cs +++ b/PluralKit.Bot/Commands/MemberProxy.cs @@ -63,7 +63,7 @@ public class MemberProxy if (!ctx.HasNext(false)) throw new PKSyntaxError("You must pass an example proxy to add (eg. `[text]` or `J:text`)."); - var tagToAdd = ParseProxyTags(ctx.RemainderOrNull(false)); + var tagToAdd = ParseProxyTags(ctx.RemainderOrNull(false).NormalizeLineEndSpacing()); if (tagToAdd.IsEmpty) throw Errors.EmptyProxyTags(target, ctx); if (target.ProxyTags.Contains(tagToAdd)) throw Errors.ProxyTagAlreadyExists(tagToAdd, target); @@ -87,10 +87,17 @@ public class MemberProxy if (!ctx.HasNext(false)) throw new PKSyntaxError("You must pass a proxy tag to remove (eg. `[text]` or `J:text`)."); - var tagToRemove = ParseProxyTags(ctx.RemainderOrNull(false)); + var remainder = ctx.RemainderOrNull(false); + var tagToRemove = ParseProxyTags(remainder.NormalizeLineEndSpacing()); if (tagToRemove.IsEmpty) throw Errors.EmptyProxyTags(target, ctx); if (!target.ProxyTags.Contains(tagToRemove)) - throw Errors.ProxyTagDoesNotExist(tagToRemove, target); + { + // Legacy support for when line endings weren't normalized + tagToRemove = ParseProxyTags(remainder); + if (!target.ProxyTags.Contains(tagToRemove)) + throw Errors.ProxyTagDoesNotExist(tagToRemove, target); + } + var newTags = target.ProxyTags.ToList(); newTags.Remove(tagToRemove); @@ -102,7 +109,7 @@ public class MemberProxy // Subcommand: bare proxy tag given else { - var requestedTag = ParseProxyTags(ctx.RemainderOrNull(false)); + var requestedTag = ParseProxyTags(ctx.RemainderOrNull(false).NormalizeLineEndSpacing()); if (requestedTag.IsEmpty) throw Errors.EmptyProxyTags(target, ctx); // This is mostly a legacy command, so it's gonna warn if there's