fix: fix support for Discord timestamps

This commit is contained in:
Oliver Booth 2023-08-27 16:50:33 +01:00
parent eef18ec1d3
commit a49b065ee2
Signed by: oliverbooth
GPG Key ID: B89D139977693FED
1 changed files with 8 additions and 0 deletions

View File

@ -78,9 +78,15 @@ public static class MentionUtility
using Utf8ValueStringBuilder buffer = ZString.CreateUtf8StringBuilder(); using Utf8ValueStringBuilder buffer = ZString.CreateUtf8StringBuilder();
var formatSpecifier = '\0'; var formatSpecifier = '\0';
var isEscaped = false; var isEscaped = false;
var breakLoop = false;
for (var index = 2; index < contents.Length; index++) for (var index = 2; index < contents.Length; index++)
{ {
if (breakLoop)
{
break;
}
char current = contents[index]; char current = contents[index];
switch (current) switch (current)
{ {
@ -90,6 +96,8 @@ public static class MentionUtility
case ':' when !isEscaped && index + 1 < contents.Length: case ':' when !isEscaped && index + 1 < contents.Length:
formatSpecifier = contents[index + 1]; formatSpecifier = contents[index + 1];
if (formatSpecifier == '>') formatSpecifier = '\0'; // ignore closing tag
breakLoop = true;
break; break;
case '>' when !isEscaped: case '>' when !isEscaped: