Fix <text> brackets also matching markdown

This commit is contained in:
Fiona 2021-09-26 20:23:59 -04:00 committed by spiral
parent 7d60b3e7cf
commit 94f4f970ea
No known key found for this signature in database
GPG Key ID: A6059F0CA0E1BD31

View File

@ -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<ProxyMember> 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))
{