From 525bd02022066d8c418d5eb53d4a2f37bea6eb72 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Thu, 31 Oct 2024 21:20:16 +0100 Subject: [PATCH] [backend/libmfm] Fix broken rendering of mentions of local users in some circumstances (ISH-567) This was caused because of an inconsistency of whether to set the account domain as a fallback value or not. Therefore, invocations with the mentioned local user host not having a fallback value would cause broken mention rendering, e.g. in bios/profile fields. --- .../Core/Helpers/LibMfm/Conversion/MfmConverter.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Iceshrimp.Backend/Core/Helpers/LibMfm/Conversion/MfmConverter.cs b/Iceshrimp.Backend/Core/Helpers/LibMfm/Conversion/MfmConverter.cs index 89ed7cd2..0556acc4 100644 --- a/Iceshrimp.Backend/Core/Helpers/LibMfm/Conversion/MfmConverter.cs +++ b/Iceshrimp.Backend/Core/Helpers/LibMfm/Conversion/MfmConverter.cs @@ -193,7 +193,7 @@ public class MfmConverter(IOptions config) var punyHost = host?.ToPunycodeLower(); if (emoji?.FirstOrDefault(p => p.Name == emojiCodeNode.Name && p.Host == punyHost) is { } hit) { - var el = document.CreateElement("span"); + var el = document.CreateElement("span"); var inner = document.CreateElement("img"); inner.SetAttribute("src", hit.PublicUrl); el.AppendChild(inner); @@ -246,9 +246,13 @@ public class MfmConverter(IOptions config) if (finalHost == config.Value.WebDomain) finalHost = config.Value.AccountDomain; - var mention = mentions.FirstOrDefault(p => p.Username.EqualsIgnoreCase(mentionNode.Username) && - p.Host.EqualsIgnoreCase(finalHost)); - if (mention == null) + Func predicate = finalHost == config.Value.AccountDomain + ? p => p.Username.EqualsIgnoreCase(mentionNode.Username) && + (p.Host.EqualsIgnoreCase(finalHost) || p.Host == null) + : p => p.Username.EqualsIgnoreCase(mentionNode.Username) && + p.Host.EqualsIgnoreCase(finalHost); + + if (mentions.FirstOrDefault(predicate) is not { } mention) { el.TextContent = $"@{mentionNode.Acct}"; }