From bc2cfbeba3a3dc00f13e2c959853b1f24746a6f1 Mon Sep 17 00:00:00 2001 From: spiral <spiral@spiral.sh> Date: Sun, 24 Apr 2022 14:51:47 -0400 Subject: [PATCH] fix: check if member target is 5-length alpha before trying to search by HID (#441) --- .../CommandSystem/Context/ContextEntityArgumentsExt.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PluralKit.Bot/CommandSystem/Context/ContextEntityArgumentsExt.cs b/PluralKit.Bot/CommandSystem/Context/ContextEntityArgumentsExt.cs index 6088b8a8..2a79b7d2 100644 --- a/PluralKit.Bot/CommandSystem/Context/ContextEntityArgumentsExt.cs +++ b/PluralKit.Bot/CommandSystem/Context/ContextEntityArgumentsExt.cs @@ -1,3 +1,5 @@ +using System.Text.RegularExpressions; + using Myriad.Extensions; using Myriad.Types; @@ -79,7 +81,10 @@ public static class ContextEntityArgumentsExt return memberByDisplayName; } - // Finally (or if by-HID lookup is specified), try member HID parsing: + // Finally (or if by-HID lookup is specified), check if input is a valid HID and then try member HID parsing: + + if (!Regex.IsMatch(input, @"^[a-zA-Z]{5}$")) + return null; // For posterity: // There was a bug that made `SELECT * FROM MEMBERS WHERE HID = $1` hang forever BUT