From 3fd4e7188c92f2e7042f39615bb98b64b6b27118 Mon Sep 17 00:00:00 2001 From: oykuermann <142304401+oykuermann@users.noreply.github.com> Date: Mon, 16 Nov 2026 13:26:02 +0300 Subject: [PATCH] Show a MudBlazor notification's title as markup, not as text UiNotificationAlert passed "{Title}
{Message}" to ISnackbar.Add(string), which shows a string as text, so every notification with a title showed the tags. Send it as an encoded MarkupString instead; without a title the message stays plain text. Co-Authored-By: Claude Opus 5.5 --- .../Components/UiNotificationAlert.razor.cs | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/framework/src/Volo.Abp.MudBlazorUI/Components/UiNotificationAlert.razor.cs b/framework/src/Volo.Abp.MudBlazorUI/Components/UiNotificationAlert.razor.cs index ac5c3a8c0d..eaf8804e2a 100644 --- a/framework/src/Volo.Abp.MudBlazorUI/Components/UiNotificationAlert.razor.cs +++ b/framework/src/Volo.Abp.MudBlazorUI/Components/UiNotificationAlert.razor.cs @@ -1,4 +1,5 @@ using System; +using System.Net; using System.Threading.Tasks; using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Localization; @@ -57,21 +58,33 @@ public partial class UiNotificationAlert : ComponentBase, IDisposable Title = e.Title; Options = e.Options; - var message = !string.IsNullOrEmpty(Title) - ? $"{Title}
{Message}" - : Message; - await InvokeAsync(() => { - Snackbar.Add(message, GetSeverity(e.NotificationType), config => + Action configure = config => { config.RequireInteraction = false; config.ShowCloseIcon = true; config.CloseAfterNavigation = true; - }); + }; + + // A string is shown as plain text, so the title's markup must go as a MarkupString. + // Title and message are encoded first: they can carry user input (a chat message, a name). + if (!string.IsNullOrEmpty(Title)) + { + Snackbar.Add(GetTitledMessage(Title, Message), GetSeverity(e.NotificationType), configure); + } + else + { + Snackbar.Add(Message, GetSeverity(e.NotificationType), configure); + } }); } + protected virtual MarkupString GetTitledMessage(string title, string message) + { + return new MarkupString($"{WebUtility.HtmlEncode(title)}
{WebUtility.HtmlEncode(message)}"); + } + public virtual void Dispose() { if (UiNotificationService != null)