From 94f4f970ea5828cd4469b3b44f8c9ad21f0cc960 Mon Sep 17 00:00:00 2001 From: Fiona Date: Sun, 26 Sep 2021 20:23:59 -0400 Subject: [PATCH] Fix brackets also matching markdown --- PluralKit.Bot/Proxy/ProxyTagParser.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/PluralKit.Bot/Proxy/ProxyTagParser.cs b/PluralKit.Bot/Proxy/ProxyTagParser.cs index 0b5a44c1..acaf49f0 100644 --- a/PluralKit.Bot/Proxy/ProxyTagParser.cs +++ b/PluralKit.Bot/Proxy/ProxyTagParser.cs @@ -1,6 +1,7 @@ #nullable enable using System.Collections.Generic; using System.Linq; +using System.Text.RegularExpressions; using PluralKit.Core; @@ -8,6 +9,9 @@ namespace PluralKit.Bot { public class ProxyTagParser { + private Regex prefixPattern = new Regex(@"^<(?:@!?|#|@&|a?:[\d\w_]+?:)\d+>"); + private Regex suffixPattern = new Regex(@"<(?:@!?|#|@&|a?:[\d\w_]+?:)\d+>$"); + public bool TryMatch(IEnumerable members, string? input, out ProxyMatch result) { result = default; @@ -36,6 +40,9 @@ namespace PluralKit.Bot // Skip blank tags (shouldn't ever happen in practice) if (tag.Prefix == null && tag.Suffix == null) continue; + if(tag.Prefix == "<" && prefixPattern.IsMatch(input)) continue; + if(tag.Suffix == ">" && suffixPattern.IsMatch(input)) continue; + // Can we match with these tags? if (TryMatchTagsInner(input, tag, out result.Content)) {