Switched to SAFE_MARKDOWN_PIPELINE

This commit is contained in:
Thorsten Sommer 2026-02-25 21:27:48 +01:00
parent 0fdaf19168
commit 1353345311
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108
12 changed files with 25 additions and 26 deletions

View File

@ -96,10 +96,10 @@
} }
else else
{ {
<MudMarkdown Value="@this.NormalizeMarkdownForRendering(textContent.Text)" Props="Markdown.DefaultConfig" Styling="@this.MarkdownStyling" MarkdownPipeline="Markdown.SecurePipeline" /> <MudMarkdown Value="@NormalizeMarkdownForRendering(textContent.Text)" Props="Markdown.DefaultConfig" Styling="@this.MarkdownStyling" MarkdownPipeline="Markdown.SAFE_MARKDOWN_PIPELINE" />
@if (textContent.Sources.Count > 0) @if (textContent.Sources.Count > 0)
{ {
<MudMarkdown Value="@textContent.Sources.ToMarkdown()" Props="Markdown.DefaultConfig" Styling="@this.MarkdownStyling" MarkdownPipeline="Markdown.SecurePipeline" /> <MudMarkdown Value="@textContent.Sources.ToMarkdown()" Props="Markdown.DefaultConfig" Styling="@this.MarkdownStyling" MarkdownPipeline="Markdown.SAFE_MARKDOWN_PIPELINE" />
} }
} }
} }
@ -135,4 +135,4 @@
} }
} }
</MudCardContent> </MudCardContent>
</MudCard> </MudCard>

View File

@ -97,6 +97,7 @@ public partial class ContentBlockComponent : MSGComponentBase
return base.OnParametersSetAsync(); return base.OnParametersSetAsync();
} }
/// <inheritdoc />
protected override bool ShouldRender() protected override bool ShouldRender()
{ {
var currentRenderHash = this.CreateRenderHash(); var currentRenderHash = this.CreateRenderHash();
@ -167,7 +168,7 @@ public partial class ContentBlockComponent : MSGComponentBase
switch (this.Content) switch (this.Content)
{ {
case ContentText text: case ContentText text:
var textValue = text.Text ?? string.Empty; var textValue = text.Text;
hash.Add(textValue.Length); hash.Add(textValue.Length);
hash.Add(textValue.GetHashCode(StringComparison.Ordinal)); hash.Add(textValue.GetHashCode(StringComparison.Ordinal));
hash.Add(text.Sources.Count); hash.Add(text.Sources.Count);
@ -193,7 +194,7 @@ public partial class ContentBlockComponent : MSGComponentBase
CodeBlock = { Theme = this.CodeColorPalette }, CodeBlock = { Theme = this.CodeColorPalette },
}; };
private string NormalizeMarkdownForRendering(string text) private static string NormalizeMarkdownForRendering(string text)
{ {
var cleaned = text.RemoveThinkTags().Trim(); var cleaned = text.RemoveThinkTags().Trim();
if (string.IsNullOrWhiteSpace(cleaned)) if (string.IsNullOrWhiteSpace(cleaned))
@ -293,4 +294,4 @@ public partial class ContentBlockComponent : MSGComponentBase
var result = await ReviewAttachmentsDialog.OpenDialogAsync(this.DialogService, this.Content.FileAttachments.ToHashSet()); var result = await ReviewAttachmentsDialog.OpenDialogAsync(this.DialogService, this.Content.FileAttachments.ToHashSet());
this.Content.FileAttachments = result.ToList(); this.Content.FileAttachments = result.ToList();
} }
} }

View File

@ -6,4 +6,4 @@
} }
</MudSelect> </MudSelect>
<MudMarkdown Value="@this.LogContent" Props="Markdown.DefaultConfig" MarkdownPipeline="Markdown.SecurePipeline"/> <MudMarkdown Value="@this.LogContent" Props="Markdown.DefaultConfig" MarkdownPipeline="Markdown.SAFE_MARKDOWN_PIPELINE"/>

View File

@ -127,4 +127,4 @@
<MudIconButton /> <MudIconButton />
</MudToolBar> </MudToolBar>
</FooterContent> </FooterContent>
</InnerScrolling> </InnerScrolling>

View File

@ -28,7 +28,7 @@
<MudText Typo="Typo.h6"> <MudText Typo="Typo.h6">
@T("Description") @T("Description")
</MudText> </MudText>
<MudMarkdown Value="@this.currentConfidence.Description" MarkdownPipeline="Markdown.SecurePipeline"/> <MudMarkdown Value="@this.currentConfidence.Description" MarkdownPipeline="Markdown.SAFE_MARKDOWN_PIPELINE"/>
@if (this.currentConfidence.Sources.Count > 0) @if (this.currentConfidence.Sources.Count > 0)
{ {
@ -67,4 +67,4 @@
</MudCardActions> </MudCardActions>
</MudCard> </MudCard>
</MudPopover> </MudPopover>
</div> </div>

View File

@ -104,7 +104,7 @@
@context.ToName() @context.ToName()
</MudTd> </MudTd>
<MudTd> <MudTd>
<MudMarkdown Value="@context.GetConfidence(this.SettingsManager).Description" MarkdownPipeline="Markdown.SecurePipeline"/> <MudMarkdown Value="@context.GetConfidence(this.SettingsManager).Description" MarkdownPipeline="Markdown.SAFE_MARKDOWN_PIPELINE"/>
</MudTd> </MudTd>
<MudTd Style="vertical-align: top;"> <MudTd Style="vertical-align: top;">
<MudMenu StartIcon="@Icons.Material.Filled.Security" EndIcon="@Icons.Material.Filled.KeyboardArrowDown" Label="@this.GetCurrentConfidenceLevelName(context)" Variant="Variant.Filled" Style="@this.SetCurrentConfidenceLevelColorStyle(context)"> <MudMenu StartIcon="@Icons.Material.Filled.Security" EndIcon="@Icons.Material.Filled.KeyboardArrowDown" Label="@this.GetCurrentConfidenceLevelName(context)" Variant="Variant.Filled" Style="@this.SetCurrentConfidenceLevelColorStyle(context)">

View File

@ -54,7 +54,7 @@
Class="ma-2 pe-4" Class="ma-2 pe-4"
HelperText="@T("This is the content we loaded from your file — including headings, lists, and formatting. Use this to verify your file loads as expected.")"> HelperText="@T("This is the content we loaded from your file — including headings, lists, and formatting. Use this to verify your file loads as expected.")">
<div style="max-height: 40vh; overflow-y: auto;"> <div style="max-height: 40vh; overflow-y: auto;">
<MudMarkdown Value="@this.FileContent" Props="Markdown.DefaultConfig" Styling="@this.MarkdownStyling" MarkdownPipeline="Markdown.SecurePipeline"/> <MudMarkdown Value="@this.FileContent" Props="Markdown.DefaultConfig" Styling="@this.MarkdownStyling" MarkdownPipeline="Markdown.SAFE_MARKDOWN_PIPELINE"/>
</div> </div>
</MudField> </MudField>
</MudTabPanel> </MudTabPanel>
@ -83,4 +83,4 @@
@T("Close") @T("Close")
</MudButton> </MudButton>
</DialogActions> </DialogActions>
</MudDialog> </MudDialog>

View File

@ -30,7 +30,7 @@
} }
else if (!string.IsNullOrWhiteSpace(this.licenseText)) else if (!string.IsNullOrWhiteSpace(this.licenseText))
{ {
<MudMarkdown Value="@this.licenseText" Props="Markdown.DefaultConfig" MarkdownPipeline="Markdown.SecurePipeline"/> <MudMarkdown Value="@this.licenseText" Props="Markdown.DefaultConfig" MarkdownPipeline="Markdown.SAFE_MARKDOWN_PIPELINE"/>
} }
</ExpansionPanel> </ExpansionPanel>
@ -226,4 +226,4 @@
} }
} }
</DialogActions> </DialogActions>
</MudDialog> </MudDialog>

View File

@ -5,7 +5,7 @@
<MudIcon Icon="@Icons.Material.Filled.Update" Size="Size.Large" Class="mr-3"/> <MudIcon Icon="@Icons.Material.Filled.Update" Size="Size.Large" Class="mr-3"/>
@this.HeaderText @this.HeaderText
</MudText> </MudText>
<MudMarkdown Value="@this.UpdateResponse.Changelog" Props="Markdown.DefaultConfig" MarkdownPipeline="Markdown.SecurePipeline"/> <MudMarkdown Value="@this.UpdateResponse.Changelog" Props="Markdown.DefaultConfig" MarkdownPipeline="Markdown.SAFE_MARKDOWN_PIPELINE"/>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled"> <MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
@ -15,4 +15,4 @@
@T("Install now") @T("Install now")
</MudButton> </MudButton>
</DialogActions> </DialogActions>
</MudDialog> </MudDialog>

View File

@ -27,7 +27,7 @@
</ExpansionPanel> </ExpansionPanel>
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.EventNote" HeaderText="@T("Last Changelog")"> <ExpansionPanel HeaderIcon="@Icons.Material.Filled.EventNote" HeaderText="@T("Last Changelog")">
<MudMarkdown Value="@this.LastChangeContent" Props="Markdown.DefaultConfig" MarkdownPipeline="Markdown.SecurePipeline"/> <MudMarkdown Value="@this.LastChangeContent" Props="Markdown.DefaultConfig" MarkdownPipeline="Markdown.SAFE_MARKDOWN_PIPELINE"/>
</ExpansionPanel> </ExpansionPanel>
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Lightbulb" HeaderText="@T("Vision")"> <ExpansionPanel HeaderIcon="@Icons.Material.Filled.Lightbulb" HeaderText="@T("Vision")">
@ -35,9 +35,9 @@
</ExpansionPanel> </ExpansionPanel>
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.RocketLaunch" HeaderText="@T("Quick Start Guide")"> <ExpansionPanel HeaderIcon="@Icons.Material.Filled.RocketLaunch" HeaderText="@T("Quick Start Guide")">
<MudMarkdown Props="Markdown.DefaultConfig" Value="@QUICK_START_GUIDE" MarkdownPipeline="Markdown.SecurePipeline"/> <MudMarkdown Props="Markdown.DefaultConfig" Value="@QUICK_START_GUIDE" MarkdownPipeline="Markdown.SAFE_MARKDOWN_PIPELINE"/>
</ExpansionPanel> </ExpansionPanel>
</MudExpansionPanels> </MudExpansionPanels>
</InnerScrolling> </InnerScrolling>
</div> </div>

View File

@ -297,8 +297,8 @@
</MudGrid> </MudGrid>
</ExpansionPanel> </ExpansionPanel>
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Verified" HeaderText="License: FSL-1.1-MIT"> <ExpansionPanel HeaderIcon="@Icons.Material.Filled.Verified" HeaderText="License: FSL-1.1-MIT">
<MudMarkdown Value="@LICENSE" Props="Markdown.DefaultConfig" MarkdownPipeline="Markdown.SecurePipeline"/> <MudMarkdown Value="@LICENSE" Props="Markdown.DefaultConfig" MarkdownPipeline="Markdown.SAFE_MARKDOWN_PIPELINE"/>
</ExpansionPanel> </ExpansionPanel>
</MudExpansionPanels> </MudExpansionPanels>
</InnerScrolling> </InnerScrolling>
</div> </div>

View File

@ -4,13 +4,11 @@ namespace AIStudio.Tools;
public static class Markdown public static class Markdown
{ {
private static readonly MarkdownPipeline SAFE_MARKDOWN_PIPELINE = new MarkdownPipelineBuilder() public static readonly MarkdownPipeline SAFE_MARKDOWN_PIPELINE = new MarkdownPipelineBuilder()
.UseAdvancedExtensions() .UseAdvancedExtensions()
.DisableHtml() .DisableHtml()
.Build(); .Build();
public static MarkdownPipeline SecurePipeline => SAFE_MARKDOWN_PIPELINE;
public static MudMarkdownProps DefaultConfig => new() public static MudMarkdownProps DefaultConfig => new()
{ {
Heading = Heading =
@ -28,4 +26,4 @@ public static class Markdown
}, },
} }
}; };
} }